public void removeElement(T element) { final int elementRow = myTableModel.getElementRow(element); if (elementRow < 0) { return; // no such element } final boolean wasSelected = myTable.getSelectionModel().isSelectedIndex(elementRow); myTableModel.removeElement(element); myElementToPropertiesMap.remove(element); if (wasSelected) { final int rowCount = myTableModel.getRowCount(); if (rowCount > 0) { selectRow(elementRow % rowCount); } else { myTable.getSelectionModel().clearSelection(); } } myTable.requestFocus(); }