import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SimpleTable extends JFrame { public SimpleTable() { super("Simple JTable Test"); //Create the table and give the data as a two-dimensional //String array and the column headers as a one-dimensional String array. JTable jt = new JTable(new String[][] { {"This", "is"}, {"a", "Test"} }, new String[] {"Column 1", "Column 2"}); //Place the table in a scrollpane. This is the simplest //way to make it scollable. JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); //Show the frame. setSize(300, 200); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); } public static void main(String args[]) { new SimpleTable(); } }