package three.day.frame;
import javax.swing.JFrame;import javax.swing.JScrollPane;
import javax.swing.JTable;
public class JTableDemo02 {
public static void main(String[] args) {
Object[][] rowData = {
{"sd001","张三","21","09会计(1)"},
{"sd023","李四","22","09会计(1)"},
{"sd089","王五","23","09会计(2)"},
{"sd112","赵六","24","09会计(3)"},
{"sd201","钱七","23","09会计(4)"}
};
Object[] columnNames = {"编号","姓名","年龄","班级"};
JTable table = new JTable(rowData,columnNames);
JScrollPane pane1 = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
JFrame frame = new JFrame("JTable的使用示例");
frame.add(pane1);
frame.setBounds(300,200,500,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}