I have a sortable default table model with ListSelectionListener that listens for a doubleclick and then opens a details view of a particular column. This works fine, however, when I sort a column the listener no longer functions.
JTable foosTable = new JTable(model);
TableRowSorter<TableModel> fooSorter = new TableRowSorter<TableModel>(model);
foosTable.setRowSorter(fooSorter);
ListSelectionModel listMod = foosTable.getSelectionModel();
listMod.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionListener barListener = new ListSelectionListener(foosTable);
listMod.addListSelectionListener(barListener);
I have never used TableRowListener which seems to only have an
itemChangedevent. I usually stick to standard swing. Add a mouse listener to the table, grab the location of a click event and then handle it.Edit
Setup a TableRowSorter:
Because you are changing the row order, you will need to use convertColumnIndexToModel
to get the correct model data for the view.
For more complex sorting/filtering needs you may want to try glazed lists.