Example usage for javax.swing JTable setColumnSelectionAllowed

List of usage examples for javax.swing JTable setColumnSelectionAllowed

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, description = "If true, an entire column is selected for each selected cell.")
public void setColumnSelectionAllowed(boolean columnSelectionAllowed) 

Source Link

Document

Sets whether the columns in this model can be selected.

Usage

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 . j a va 2 s.c o 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(true);//from w w  w  . ja va2s. c  o  m

    int row = 2;
    int col = 1;
    boolean toggle = false;
    boolean extend = false;
    table.changeSelection(row, col, 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);

    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);//from  w  w  w  .j  a va2 s. c  o m

    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 a  2  s.  co  m

    table.removeRowSelectionInterval(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.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);/*from   w ww. ja  va  2s. c  o m*/

    table.addRowSelectionInterval(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  . j  a v a 2 s.  c om*/

    int row = 3;
    int col = 2;
    boolean toggle = true;
    boolean extend = false;
    table.changeSelection(row, col, 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(true);//w  w w .  ja va 2  s  . co  m

    int row = 5;
    int col = 3;
    boolean toggle = false;
    boolean extend = true;
    table.changeSelection(row, col, toggle, extend);

}

From source file:Main.java

/**
 * Disable any selections on a table.//from   w ww  .  j a  va  2s  . c o  m
 */
public static void disableSelection(JTable table) {
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);
    table.setCellSelectionEnabled(false);
    table.setFocusable(false);
}

From source file:MainClass.java

public MainClass() {
    super("Simple JTable Test");
    setSize(300, 200);//from ww w .j ava2  s  .  c o m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    File pwd = new File(".");
    Object[][] stats = getFileStats(pwd);

    JTable jt = new JTable(stats, titles);
    jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    jt.setColumnSelectionAllowed(true);

    JScrollPane jsp = new JScrollPane(jt);
    getContentPane().add(jsp, BorderLayout.CENTER);
}