Example usage for javax.swing JTable addRowSelectionInterval

List of usage examples for javax.swing JTable addRowSelectionInterval

Introduction

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

Prototype

public void addRowSelectionInterval(int index0, int index1) 

Source Link

Document

Adds the rows from index0 to index1, inclusive, to the current selection.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame("Test");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTable table = new JTable(new String[][] { { "One" }, { "Two" }, { "Three" } }, new String[] { "Ordinal" });
    table.addRowSelectionInterval(1, 1);
    f.add(new JScrollPane(table));
    f.pack();//from  w w  w  .  java  2 s  .  c  o  m
    f.setLocationRelativeTo(null);
    f.setVisible(true);

}

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);/*  www . j  a va  2  s . c o m*/

    table.addRowSelectionInterval(1, 2);
}