void () { int[] selected = myExcludedTable.getSelectedRows(); if(selected == null || selected.length <= 0) { return; } if(myExcludedTable.isEditing()) { TableCellEditor editor = myExcludedTable.getCellEditor(); if (editor != null) { editor.stopCellEditing(); } } AbstractTableModel model = (AbstractTableModel)myExcludedTable.getModel(); Arrays.sort(selected); int indexToSelect = selected[selected.length - 1]; int removedCount = 0; for (int indexToRemove : selected) { final int row = indexToRemove - removedCount; ExcludeEntryDescription description = myExcludeEntryDescriptions.get(row); Disposer.dispose(description); myExcludeEntryDescriptions.remove(row); model.fireTableRowsDeleted(row, row); removedCount += 1; } if(indexToSelect >= myExcludeEntryDescriptions.size()) { indexToSelect = myExcludeEntryDescriptions.size() - 1; } if(indexToSelect >= 0) { myExcludedTable.setRowSelectionInterval(indexToSelect, indexToSelect); } IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myExcludedTable, true)); }