JTable auto row sorter index of sorting column

66 Views Asked by At

I'm trying to make a custom row header renderer, to change the color of the header to for example red, of the column that's table is sorted by. this part I managed by renderer from this tutorial JTable column header custom renderer examples and invoking:

TableColumn column = table.getColumnModel().getColumn(indexOfColumn);

column.setHeaderRenderer(new KeepSortIconHeaderRenderer(
    table.getTableHeader().getDefaultRenderer()));

For sorting, I use auto row sorter. I need to get the index of the column that the user sorted by so I can pass that index to the code above. Is there any fuction I can use? Closest I managed to get is overriding toggleSortOrder but that override the whole auto row sorter so it's stopped working.

0

There are 0 best solutions below