Main.java
01 /**
02  *
03  * All content copyright (c) 2003-2008 Terracotta, Inc.,
04  * except as may otherwise be noted in a separate copyright notice.
05  * All rights reserved.
06  *
07  */
08 package demo.jtable;
09 
10 import java.awt.Font;
11 import javax.swing.JFrame;
12 import javax.swing.JScrollPane;
13 import javax.swing.JTable;
14 import javax.swing.table.DefaultTableModel;
15 
16 /**
17  *  Description of the Class
18  *
19  *@author    Terracotta, Inc.
20  */
21 class Main extends JFrame {
22    private DefaultTableModel model;
23 
24    private Object[] tableHeader = {"Time""Room A""Room B""Room C"};
25 
26    private static Object[][] tableData = {{" 9:00"""""""},
27          {"10:00"""""""}{"11:00"""""""},
28          {"12:00"""""""}{" 1:00"""""""},
29          {" 2:00"""""""}{" 3:00"""""""},
30          {" 4:00"""""""}{" 5:00"""""""}};
31 
32    Main() {
33       super("Table Demo");
34 
35       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
36       setDefaultLookAndFeelDecorated(true);
37 
38       model = new DefaultTableModel(tableData, tableHeader);
39 
40       JTable table = new JTable(model);
41       table.setFont(new Font("Courier New", Font.PLAIN, 14));
42       getContentPane().add(new JScrollPane(table));
43       setSize(500200);
44       setVisible(true);
45    }
46 
47    public static void main(String[] args) {
48       javax.swing.SwingUtilities.invokeLater(
49                new Runnable() {
50                   public void run() {
51                      new Main();
52                   }
53                });
54    }
55 }