Reputation: 375
I have an ArrayList containing multiple elements, each element contains the next fields:
I have a JTable to show the information contained in the ArrayList. I have a TableRowSorter to filter the information, according to a certain field.
Let´s say after filtering I get only one element, therefore the JTable has now one row. How can I get the index of that element in the original ArrayList? Do I have to implement one more field kind of "ID"?
Upvotes: 0
Views: 630
Reputation: 691715
int viewIndex = 0; // the index in the table of the unique filtered row.
int modelIndex = table.convertRowIndexToModel();
modelIndex
is the index of the row in the list backing the table model.
Upvotes: 2