- , . , , , .
The fastest way for tables with over several hundred rows is
public static void invertSelection(JTable table) {
ListSelectionModel mdl = table.getSelectionModel();
int[] selected = table.getSelectedRows();
mdl.setValueIsAdjusting(true);
mdl.setSelectionInterval(0, table.getRowCount() - 1);
for (int i : selected) {
mdl.removeSelectionInterval(i, i);
}
mdl.setValueIsAdjusting(false);
}
Ayman source
share