void () { Set<ClasspathTableItem<?>> oldSelection = new HashSet<>(); for (int i : myEntryTable.getSelectedRows()) { ContainerUtil.addIfNotNull(oldSelection, getItemAt(i)); } myModel.clear(); myModel.init(); myModel.fireTableDataChanged(); IntList newSelection = new IntArrayList(); for (int i = 0; i < myModel.getRowCount(); i++) { if (oldSelection.contains(getItemAt(i))) { newSelection.add(i); } } TableUtil.selectRows(myEntryTable, newSelection.toIntArray()); }