views:

370

answers:

2

Is is possible to some how get the index of the selection corresponding to the non filtered table?

After the table is filter using a regexFilter. JTable getSelectedRow returns the index of the filtered table?

A: 

store the row id in your datamodel, when you get the selected row from jtable, query that rows ID.

aepurniet
+2  A: 

If you are using the built in TableRowSorter functionality from 1.6 you can use the convertRowIndexToModel() on the table. This is give you the unfiltered index of the selected row.

The javadoc for JTable gives a description of this:

Coordinate conversions will be necessary when using the row based methods of JTable with the underlying TableModel. All of JTables row based methods are in terms of the RowSorter, which is not necessarily the same as that of the underlying TableModel. For example, the selection is always in terms of JTable so that when using RowSorter you will need to convert using convertRowIndexToView or convertRowIndexToModel.

Aaron