I am using AbstractTableModel to display a table of data in the GUI. In this table, on double-clicking a particular row, a pop-up window is displayed and on pressing "ok", the pop-up is closed. After this, the highlighted row goes to the first row of the table. I would like to know how to highlight the same row which has been clicked, rather than highlighting the first row always (after the pop-up is closed, ie, after the call to setValueAt() of this table model). For eg., if there are more no. of rows in the table, after clicking a particular row in the bottom, opening and closing the pop-up window, the highlight again goes back to the first row after which I have to scroll down back to the previously clicked row. Is it feasible to have the highlight on the same row?
Originally posted by ram shyam: Hi all, ...Is it feasible to have the highlight on the same row?
The AbstractTableModel or rather any table model is not aware of selections. It is handled by the ListSelectionModel. You will need to remember the current selection and reset it back after editing. Take a look at JTable#getSelectionModel and ListSelectionModel#setSelectionInterval.