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);
}
});