Reputation: 16050
There is JTable, and one of columns has Date format. I need to sort table entries according to this column (Date).
To solve this task, I created a class TableSorter (http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TableSorterDemoProject/src/components/TableSorter.java). Then I added the following lines in the code:
TableSorter sorter = new TableSorter(tableModel);
sorter.setTableHeader(table.getTableHeader());
When I run the program, I can see only small triagles added to headers, but ordering does not work.
Any ideas?
Upvotes: 1
Views: 1787
Reputation: 109813
you have to add TableSorter
to the TableModel
as is described in the JTables tutorial about Sorting and Filtering
Upvotes: 4