FileDocCategorySizeDatePackage
TableSorterDemo.javaAPI DocExample5445Tue Dec 12 18:59:18 GMT 2000None

TableSorterDemo

public class TableSorterDemo extends JFrame

Fields Summary
private boolean
DEBUG
Constructors Summary
public TableSorterDemo()


      
        super("TableSorterDemo");

        MyTableModel myModel = new MyTableModel();
        TableSorter sorter = new TableSorter(myModel); //ADDED THIS
        //JTable table = new JTable(myModel);          //OLD
        JTable table = new JTable(sorter);             //NEW
        sorter.addMouseListenerToHeaderInTable(table); //ADDED THIS
        table.setPreferredScrollableViewportSize(new Dimension(500, 70));

        //Create the scroll pane and add the table to it. 
        JScrollPane scrollPane = new JScrollPane(table);

        //Add the scroll pane to this window.
        getContentPane().add(scrollPane, BorderLayout.CENTER);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    
Methods Summary
public static voidmain(java.lang.String[] args)

        TableSorterDemo frame = new TableSorterDemo();
        frame.pack();
        frame.setVisible(true);