void (ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 <= index && index < tableModel.getRowCount()) { tableModel.removeRow(index); if (index < tableModel.getRowCount()) { table.setRowSelectionInterval(index, index); } else { if (index > 0) { table.setRowSelectionInterval(index - 1, index - 1); } } updateButtons(table, tableModel, addButton, removeButton, upButton, downButton); } table.getParent().repaint(); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); }