当前位置:主页 > 软件编程 > JAVA代码 >

java之swing表格实现方法

时间:2023-02-24 09:16:10 | 栏目:JAVA代码 | 点击:

本文实例讲述了java之swing表格实现方法。分享给大家供大家参考。具体如下:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
public class test extends JApplet{
  public void init(){
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    final String[] colHeads = {"Name", "Phone", "Fax"};
    final Object[][] data={
        {"cai", "1122","1122" },
        {"jie", "2222","2222" },
        {"tt", "3322","3322" }
    };
    JTable table = new JTable(data, colHeads);
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
    JScrollPane jsp = new JScrollPane(table, v, h);
    contentPane.add(jsp, BorderLayout.CENTER);
  }
}

希望本文所述对大家的java程序设计有所帮助。

您可能感兴趣的文章:

相关文章