SwingX 1.6.x
Sorting
With SwingX 1.6 on Java 1.6 there's only one supported way to do sorting with Glazed Lists and JXTable using TableComparatorChooser:
Approach: TableComparatorChooser
JXTable table = ...
table.setSortable(false);
table.getTableHeader().setDefaultRenderer(new JTableHeader().getDefaultRenderer());
table.setAutoCreateRowSorter(false);
table.setRowSorter(null);
Benefits
Uses sort indicator icons and gesture recognizers from Glazed Lists, which are better suited for the various look and feels
Leverage TableComparatorChooser features, such as multiple comparators per column and simple sorting state persistence
Drawbacks
The code to restore the default header renderer is ugly
You have to ensure that the RowSorter is null
Introducing JXTableSupport
To hide the ugly details of setting up JXTable to work with GlazedLists the nightly build of GlazedLists offers the new helper class JXTableSupport, so you don't need to code the above but the following:
JXTable table = ...
JXTableSupport<Issue> tableSupport = JXTableSupport.<Issue>install(
table, // the JXTable
myIssues, // the EventList for TableModel and SelectionModel
new IssueTableFormat(), // the TableFormat
sortedIssues, // the SortedList for TableComparatorChooser
TableComparatorChooser.SINGLE_COLUMN // the SortingStrategy for TableComparatorChooser );
...
// dispose after use
tableSupport.dispose();
This will create an EventTableModel, EventSelectionModel and TableComparatorChooser for you and configure the JXTable instance for use with GlazedLists.
For details, please see the Javadoc and/or source code.