Tables in Swing

Tables represent one of the most common formats for viewing data. Database records are easy to sort and choose from a table. Statistics on disk usage can be displayed for several computers or several time periods all at once. Stock market quotes can be tracked. And where would sales presentations be without tables? Well, the JTable class in the Swing package now gives you access to a single component that can handle all of the preceding examples and more.
Without getting fancy, you can think of tables as an obvious expression of two-dimensional data. In fact, the JTable class has a constructor that takes an Object[][] argument and displays the contents of that two-dimensional array as a table with rows and columns.

import java.awt.*;
import javax.swing.*;

public class SimpleTable extends JFrame {

	public SimpleTable() {
		super("Simple JTable Test");
		setSize(300, 200);

		JTable jt = new JTable(new String[][] { 
				{ "This", "is" }, { "a", "Test" } },
				new String[] { "Column", "Header" });
		JScrollPane jsp = new JScrollPane(jt);
		getContentPane().add(jsp, BorderLayout.CENTER);

	public static void main(String args[]) {
		SimpleTable st = new SimpleTable();