Example usage for javax.swing JTable setSelectionMode

List of usage examples for javax.swing JTable setSelectionMode

Introduction

In this page you can find the example usage for javax.swing JTable setSelectionMode.

Prototype

@BeanProperty(enumerationValues = { "ListSelectionModel.SINGLE_SELECTION",
        "ListSelectionModel.SINGLE_INTERVAL_SELECTION",
        "ListSelectionModel.MULTIPLE_INTERVAL_SELECTION" }, description = "The selection mode used by the row and column selection models.")
public void setSelectionMode(int selectionMode) 

Source Link

Document

Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JTable table = new JTable();

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JTable table = new JTable();

    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JTable table = new JTable();

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(false);

    table.removeColumnSelectionInterval(0, 1);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(false);

    table.clearSelection();// w  w w . ja  v a 2  s. c om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(false);

    // Select an additional range of columns - columns 1 to 2
    table.addColumnSelectionInterval(1, 2);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(true);//from w w  w.  ja  v a 2  s.co  m

    boolean toggle = true;
    boolean extend = false;
    table.changeSelection(1, 3, toggle, extend);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(false);

    // Select a column - column 0
    table.setColumnSelectionInterval(0, 0);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(false);

    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);/*from w  ww.  j av a  2  s  . com*/

    table.setRowSelectionInterval(0, 0);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int rows = 10;
    int cols = 5;
    JTable table = new JTable(rows, cols);

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(false);

    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);/*from   ww w.  j  a  v a2  s  .  c o  m*/

    table.removeRowSelectionInterval(0, 1);
}