List of usage examples for javax.swing JTable JTable
public JTable(final Object[][] rowData, final Object[] columnNames)
JTable
to display the values in the two dimensional array, rowData
, with column names, columnNames
. 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.setFocusable(false);/* ww w . j a v a 2 s .c o m*/ table.setCellSelectionEnabled(false); }
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); // Enable the ability to select a single cell table.setColumnSelectionAllowed(true); table.setRowSelectionAllowed(true);/* ww w. j a v a 2 s . c o m*/ if (table.getCellEditor() != null) { table.getCellEditor().stopCellEditing(); } }
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.setColumnSelectionAllowed(true); table.setRowSelectionAllowed(true);/* ww w .java 2 s . c o m*/ int row = 1; int col = 3; boolean success = table.editCellAt(row, col); if (success) { boolean toggle = false; boolean extend = false; table.changeSelection(row, col, toggle, extend); } }
From source file:Main.java
public static void main(String[] argv) { // Create a table with 10 rows and 5 columns JTable table = new JTable(10, 5); // Make the table vertically scrollable JScrollPane scrollPane = new JScrollPane(table); }
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.setColumnSelectionAllowed(true); table.setRowSelectionAllowed(true);//from w ww .j a v a2s .c o m int row = 1; int col = 3; boolean success = table.editCellAt(row, col); if (success) { boolean toggle = false; boolean extend = false; table.changeSelection(row, col, toggle, extend); } if (table.getCellEditor() != null) { table.getCellEditor().cancelCellEditing(); } }
From source file:Main.java
public static void main(String[] argv) { int rows = 3; int cols = 3; JTable table = new JTable(rows, cols); // /* w w w .j a v a2 s .co m*/ table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn col = table.getColumnModel().getColumn(0); int width = 100; col.setPreferredWidth(width); }
From source file:Main.java
public static void main(String[] argv) { JTable table = new JTable(10, 5); int rowIndex = 1; int vColIndex = 2; isCellVisible(table, rowIndex, vColIndex); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable(5, 5); int rowIndex = 1; int vColIndex = 2; scrollToCenter(table, rowIndex, vColIndex); }
From source file:Main.java
public static void main(String[] argv) throws Exception { int rows = 3; int cols = 3; JTable table = new JTable(rows, cols); TableColumn col = table.getColumnModel().getColumn(0); col.setMinWidth(100);/*from w w w .java 2 s . c o m*/ col.setMaxWidth(100); col.setPreferredWidth(100); }
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); }