sort column of table
Hi,
I'm using this
private JScrollPane spNotPlaying =new JScrollPane();
private DefaultTableModel dtmNotPlaying;
private JTable tNotPlaying;
spNotPlaying.getViewport().setView(tNotPlaying);
tNotPlaying =new JTable(dtmNotPlaying);
Can someone give me code which can sort column of table? I want to click on header (column name) and sort it.
Thanks.
Message was edited by:
boba5555
[616 byte] By [
boba5555a] at [2007-10-3 9:43:14]

Thanks.
I'm using code from this page
[url]http://java.sun.com/docs/books/tutorial/uiswing/components/examples/TableSorter.java[/url]
and setModel like this
sorter = new TableSorter(dtmNotPlaying);
tNotPlaying = new JTable(sorter);
sorter.setTableHeader(tNotPlaying.getTableHeader());
private DefaultTableModel dtmNotPlaying;
private JTable tNotPlaying;
TableSorter sorter;
When I do this
dtmNotPlaying.addRow(new Object[] {<some variables>});
I can see changes in tNotPlaying. How does dtmNotPlaying "say" to sorter (I know that sorter should "says" to tNotPlaying) that it should add new row and make it sorted or where does it "say" in code? It works, but why :)
Thanks.