For those of us who don't know Excel that well, this option allows the user to have the top X columns (X is configurable) remain fixed. Scrolling will be limited to the remaining columns. The same can be applied to the left X rows as well. If both a number of rows and a number of columns are frozen the bottom-right part contains the scrolling.
I can think of one technique to do this:
- create one JTable with the TableModel. Use a RowSorter with a RowFilter to filter out all rows with a row number >= X. This will be the table part with the header and the first X rows.
- create another JTable with the same TableModel. Again, use a RowSorter with a RowFilter to filter out all rows with a row number < X. This will be the table part with everything but the header and the first X rows.
That code works for freezing the left X columns. Now do the same for freezing the top X rows
The problem with that is the table header. You'll need to show only one (or two, if you also freeze the left X columns), but the resizing / reordering will need to work on the bottom table(s) as well. Still, by not using JScrollPane's column header, row header and other non-viewport components the solution may solve the problems I had with my code.