Here you can find the source of invertSelect(JTable table)
public static void invertSelect(JTable table)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.util.ArrayList; public class Main { public static void invertSelect(JTable table) { int[] temp = table.getSelectedRows(); ArrayList<Integer> selectedRows = new ArrayList<Integer>(); for (int index = 0; index < temp.length; index++) { selectedRows.add(temp[index]); }/*from ww w . j a v a 2 s. c o m*/ ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.clearSelection(); for (int index = 0; index < table.getRowCount(); index++) { if (!selectedRows.contains(index)) { selectionModel.addSelectionInterval(index, index); } } } }