2 years ago
#54203

Rjelinek
JTable auto row sorter index of sorting column
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.
java
swing
jtable
tablerowsorter
0 Answers
Your Answer