java之swing表格实现方法
程序员文章站
2024-03-05 18:32:01
本文实例讲述了java之swing表格实现方法。分享给大家供大家参考。具体如下:
import java.awt.*;
import java.awt.even...
本文实例讲述了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程序设计有所帮助。