fireTableDataChanged JTable focus problem
Hi,
I'm sure there must be a solution to this. I have a JTable and Custom AbtractTableModel. The model holds "current download data" and is updated every second by way of fireTableDataChanged().
The problem is that any selected rows are then unselected after the update, which is no good as i cant perform tasks on selected rows.
Any Ideas?
[367 byte] By [
jaysona] at [2007-11-27 8:51:49]

# 1
Before calling the update save the selected row in another variable and then use: -
jTable.changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
Check the API docs for the variable descriptions
# 4
Thanks, one more quick question, im using the TableSorter class that can be found in the java tutorials. Does this alter the indicies of objects in a table when sorted differently?
# 5
> Thanks, one more quick question, im using the
> TableSorter class that can be found in the java
> tutorials. Does this alter the indicies of objects in
> a table when sorted differently?
Basically the TableSorter class sits between the JTable and the TableModel.
The indices in the tablemodel don't change but the order in which the indices are displayed do (if that makes sense)
If you check the TableSorter class you should find some methods which will give you the index of the row in the model when supplied with the index of the selected row in the table.
So if you need to get the index of an item in the table model then you need to get the selected row from the table, run it through the method of the TableSorter to give you the equivalent index of the model.