import javax.swing.JTable;
import javax.swing.table.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class TableDemo extends JFrame {
    private boolean DEBUG = true;

    public TableDemo(Object[][] data, Object[] columns) {
        super("TableDemo");

        JTable table = new JTable(new DefaultTableModel(data, columns));
        table.setPreferredScrollableViewportSize(new Dimension(500, 100));

        JScrollPane scrollPane = new JScrollPane(table);

        getContentPane().add(scrollPane, BorderLayout.CENTER);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    public static void main(String[] args) {
        /*final String[] columnNames = {"First Name", 
                                      "Last Name",
                                      "Sport",
                                      "# of Years",
                                      "Vegetarian"};
        final Object[][] data = {
            {"Mary", "Campione", 
             "Snowboarding", new Integer(5), new Boolean(false)},
            {"Alison", "Huml", 
             "Rowing", new Integer(3), new Boolean(true)},
            {"Kathy", "Walrath",
             "Chasing toddlers", new Integer(2), new Boolean(false)},
            {"Mark", "Andrews",
             "Speed reading", new Integer(20), new Boolean(true)},
            {"Angela", "Lih",
             "Teaching high school", new Integer(4), new Boolean(false)}
        };*/
    	
        Object[] columnNames = null;
        Object[][] data = null;
        
        int in = Integer.parseInt(args[0]);
        columnNames = new Object[in];
		Random rnd = new Random();
		data = new Object[1][in];
		
		for(int i=0;i<in;i++)
		{
	        columnNames[i] = new Integer(i);
	        data[0][i] = new Integer(rnd.nextInt());	        
		}
		
    	
        TableDemo frame = new TableDemo(data, columnNames);
        frame.pack();
        frame.setVisible(true);
    }
}
