Hello,
I have a question about the JTable, it's RowSorter/SortKeys and the behavior, when the user clicks on the table headers.
When the user clicks on a header, that header gets sorted - first ascrending, second descrending.
When I now add the following code to the JTable, overriding the "paintComponent" method:
@Override
protected void paintComponent( Graphics g ) {
super.paintComponent( g );
for ( RowSorter.SortKey sortKey : getRowSorter().getSortKeys() )
System.out.println( "sortKey.getColumn(): " + sortKey.getColumn() + ", SortOrder: " + sortKey.getSortOrder() );
}
I get this output:
sortKey.getColumn(): 0, SortOrder: ASCENDING
When I click on the first header again, the output is
sortKey.getColumn(): 0, SortOrder: DESCENDING
When I now click on the second header, the output is
sortKey.getColumn(): 1, SortOrder: ASCENDING
sortKey.getColumn(): 0, SortOrder: DESCENDING
BUT now the rendering of the table shows, that only the second header is sorted (indicated by that little row, and the second header's background is light blue under the Windows L&F). But I have obviously two SortKeys - should the table not be sorted with those two keys, and shouldn't that be indicated by two little arrows, one in the first and the other in the second header?
The table seems only to take the first SortKey in the list into account, the second seems to be ignored, is that right?
Is there any property of the JTable class I have to set, so the sorting is done with two or more columns, also?
Thanks a lot for your help
Best reagards,
Timo