01: /*
02: @COPYRIGHT@
03: */
04: package demo.jtable;
05:
06: import java.awt.Font;
07: import javax.swing.JFrame;
08: import javax.swing.JScrollPane;
09: import javax.swing.JTable;
10: import javax.swing.table.DefaultTableModel;
11:
12: class Main extends JFrame {
13: private DefaultTableModel model;
14:
15: private Object[] tableHeader = { "Time", "Room A", "Room B",
16: "Room C" };
17:
18: private static Object[][] tableData = { { " 9:00", "", "", "" },
19: { "10:00", "", "", "" }, { "11:00", "", "", "" },
20: { "12:00", "", "", "" }, { " 1:00", "", "", "" },
21: { " 2:00", "", "", "" }, { " 3:00", "", "", "" },
22: { " 4:00", "", "", "" }, { " 5:00", "", "", "" } };
23:
24: Main() {
25: super ("Table Demo");
26:
27: setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
28: setDefaultLookAndFeelDecorated(true);
29:
30: model = new DefaultTableModel(tableData, tableHeader);
31:
32: JTable table = new JTable(model);
33: table.setFont(new Font("Courier New", Font.PLAIN, 14));
34: getContentPane().add(new JScrollPane(table));
35: setSize(500, 200);
36: setVisible(true);
37: }
38:
39: public static void main(String[] args) {
40: javax.swing.SwingUtilities.invokeLater(new Runnable() {
41: public void run() {
42: new Main();
43: }
44: });
45: }
46: }
|