Here you can find the source of invertSelection(JTable table)
public static void invertSelection(JTable table)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { public static void invertSelection(JTable table) { for (int rowCount = table.getRowCount() - 1; rowCount >= 0; rowCount--) { if (table.isRowSelected(rowCount)) { table.removeRowSelectionInterval(rowCount, rowCount); } else { table.addRowSelectionInterval(rowCount, rowCount); }/* w ww .j a v a 2s . co m*/ } } }