void () { final int[] selectedRows = getSelectedRows(); if(selectedRows.length == 0) return; Arrays.sort(selectedRows); final int originalRow = selectedRows[0]; for (int i = selectedRows.length - 1; i >= 0; i--) { final int selectedRow = selectedRows[i]; if (isValidRow(selectedRow)) { myMacros.remove(selectedRow); } } myTableModel.fireTableDataChanged(); if (originalRow < getRowCount()) { setRowSelectionInterval(originalRow, originalRow); } else if (getRowCount() > 0) { final int index = getRowCount() - 1; setRowSelectionInterval(index, index); } }