void (T element) { int modelRow = myTableModel.getElementRow(element); if (modelRow < 0) { return; // no such element } int viewRow = myTable.convertRowIndexToView(modelRow); boolean wasSelected = myTable.getSelectionModel().isSelectedIndex(viewRow); myTableModel.removeElement(element); myElementToPropertiesMap.remove(element); if (wasSelected) { final int rowCount = myTableModel.getRowCount(); if (rowCount > 0) { selectRow(viewRow % rowCount); } else { myTable.getSelectionModel().clearSelection(); } } IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTable, true)); }