void (@NotNull JTable table, int @NotNull [] viewRows) { ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.clearSelection(); int count = table.getRowCount(); for (int row : viewRows) { if (row >= 0 && row < count) { selectionModel.addSelectionInterval(row, row); } } }