首页 > 编程 > Java > 正文

java之swing表格实现方法

2019-11-26 14:59:16
字体:
来源:转载
供稿:网友

本文实例讲述了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程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表