I created a TableRowSorter for a JTable, and I was able to sort the table correctly. But is there a way to get the table back to its original state before I sorted it? I tried clicking on the table header, but it seems that it only sorts the table in ascending or descending order, and it doesn’t return the table back to its original state prior to the sort. Is it possible to un-sort the table and get it back to its original state? Thanks!
I created a TableRowSorter for a JTable , and I was able to sort
Share
The only way is to hang onto the original state and restore it when you fire an “unsort” event.
So you’ll need to maintain the original row order, in a List or array, that you can restore. You could also keep a reference to a duplicate of the original
DefaultTableModel.