List of usage examples for javax.swing JTable addRowSelectionInterval
public void addRowSelectionInterval(int index0, int index1)
index0
to index1
, inclusive, to the current selection. 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); }