void (AnActionButton button) { int row = table.getEditingRow(); int col = table.getEditingColumn(); int rowCount = table.getModel().getRowCount(); TableUtil.stopEditing(table); int[] idx = table.getSelectedRows(); Arrays.sort(idx); if (delta > 0) { idx = ArrayUtil.reverseArray(idx); } if (idx.length == 0) return; if (idx[0] + delta < 0) return; if (idx[idx.length - 1] + delta > rowCount) return; for (int i = 0; i < idx.length; i++) { tableModel.exchangeRows(idx[i], idx[i] + delta); idx[i] += delta; } TableUtil.selectRows(table, idx); TableUtil.scrollSelectionToVisible(table); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); if (row != -1 && col != -1) { int newEditingRow = row + delta; if (newEditingRow != -1 && newEditingRow < rowCount) { table.editCellAt(newEditingRow, col); } } }