Following position: I have a table J (X) with RowHeader (As a guide I used one of examples Rob Camicks Examples ). Everyone worked as expected.

On demand, the data that I get from the server already contains tablerownumber, which I have to show in rowheader, and the data should be filtered. So I expanded this example and added a filter. When I filtered the view, I saw spaces in my line numbers (for example: 1, 3, 6, ..), which is the desired effect.
To be able to filter and sort a table by its own tablerow, I added TableRowSorter . And here I began to get confused. The example uses the same TableModel and SelectionModel methods for mainTable and rowHeaderTable:
setModel( main.getModel() ); setSelectionModel( main.getSelectionModel() );
This is great since I don't need to sync them. But in regards to TableRowSorter I was unexpectedly not sure if I can or should even use the same TableRowSorter -Instance, or if I need to create a TableRowSorter for each table. At first I added the same thing to both tables as it seemed practical, but in many cases I got IndexOutOfBound-Exceptions . After some digging, I found out that this is because the TableRowSorter updated twice in each TableModelEvent , because each table (RowHeader and MainTable) itself notifies the TableRowSorter about the tables.
Now I'm not sure which way is right. The following solutions came to my mind: should I add a second TableRowSorter (one for each table) and synchronize them, or should I wrap the TableModel in a RowHeaderTable and let it not skip any events? Or maybe I should create my own RowHeaderTable, which does not notify the Sorters at all about the changes?
source share