Java JTable Select invertSelect(JTable table)

Here you can find the source of invertSelect(JTable table)

Description

invert Select

License

Open Source License

Declaration

public static void invertSelect(JTable table) 

Method Source Code


//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);
            }
        }
    }
}

Related

  1. createJCheckBoxForTable(boolean selected)
  2. disableSelection(JTable table)
  3. getSelectedCase(JTable table)
  4. getSelectedObject(JTable table)
  5. getSelectionBackground(JTable t)
  6. invertSelection(JTable table)
  7. moveSelectionDown(JTable table)
  8. selectPositions(final JTable table, final int index0, final int index1)
  9. spaceSelection(final JTable jTable)