In
How to Use Tables - Sorting sorting of tables is explained. In my application I'm so far as to be able to (pre) sort my table on one column. But I want to be able to sort on more columns. in '
How to Use Tables - Sorting' it is said "To specify the sort order and sort precedence for columns, invoke
setSortKeys. "
setSortKeys is part of the
DefaultRowSorter class. What should I do to be able to use
DefaultRowSorter.setSortKeys?
In the following code, from
said Oracle document, I changed some parts. I changed the names of the persons in the table, to make my point clear (I added two John's). I also added a row sorter to the table, and toggled the sort order. The result is that the table is displayed sorted on the first names. But the last names are not in order. I would like to be able to add a second sorter on the last names. It would be something like:
I know I need to add my own implementation of the
DefaultRowSorter to my code. But what do I need to do to let my class, in this example
TableSortDemo, communicate with my implemenation of the
DefaultRowSorter?
My questions:
How do I get the DefaultRowSorter.setSortKeys in this code?Is it possible to add a pre-sort to my table, and then remove the sorting capability from the table?
My (filched) code: