Question

On a JTable, I can select a specific row by using table.setRowSelectionInterval(rowIndex, rowIndex).

Now what I would like to do is the following:

  1. I open the frame containing the JTable and pass a specific table model element to it
  2. The matching table row gets highlighted/selected

I already made a method inside my tableModel called getElementRowIndex that returns the model index of the element I'm passing on to it. But now I can't select that row because the table is filtered using a RowFilter and so many of my RowIndexes are off or out of bounds.

I can get the current model index for a selected row by using table.convertRowIndexToModel. But what I need is something like table.convertModelIndexToRow. Is there such a thing? How can I accomplish my goal?

Was it helpful?

Solution

the inverse method is

 table.convertRowIndexToView(modelIndex)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top