List of usage examples for javax.swing JTable setAutoResizeMode
@BeanProperty(enumerationValues = { "JTable.AUTO_RESIZE_OFF", "JTable.AUTO_RESIZE_NEXT_COLUMN", "JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS", "JTable.AUTO_RESIZE_LAST_COLUMN", "JTable.AUTO_RESIZE_ALL_COLUMNS" }, description = "Whether the columns should adjust themselves automatically.") public void setAutoResizeMode(int mode)
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); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } }; String[] columnNames = { "col1", "col2" }; JTable table = new JTable(cellData, columnNames); table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } }; String[] columnNames = { "col1", "col2" }; JTable table = new JTable(cellData, columnNames); table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } }; String[] columnNames = { "col1", "col2" }; JTable table = new JTable(cellData, columnNames); table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } }; String[] columnNames = { "col1", "col2" }; JTable table = new JTable(cellData, columnNames); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } }; String[] columnNames = { "col1", "col2" }; JTable table = new JTable(cellData, columnNames); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); }
From source file:Main.java
public static void main(String[] argv) { int rows = 3; int cols = 3; JTable table = new JTable(rows, cols); // /* www . j a v a 2 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[] args) { Object[][] rowData = {};/*from w w w. j av a 2 s . co m*/ Object[] columnNames = { "Column 1", "Column 2", "Column 3" }; DefaultTableModel listTableModel; listTableModel = new DefaultTableModel(rowData, columnNames); for (int i = 1; i < 25; i++) { String rowString = "Quiz #" + i; listTableModel.addRow(new Object[] { rowString, "ICON", "ICON" }); } JTable listTable; listTable = new JTable(listTableModel); listTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); listTable.setCellEditor(null); listTable.setBounds(37, 143, 397, 183); JFrame frame = new JFrame(); frame.add(new JScrollPane(listTable)); frame.setVisible(true); frame.pack(); }
From source file:MainClass.java
public static void main(final String args[]) { final Object rows[][] = { { "one", "1" }, { "two", "2" }, { "three", "3" } }; final String headers[] = { "English", "Digit" }; TableModel fixedColumnModel = new AbstractTableModel() { public int getColumnCount() { return 2; }//from w w w . j a va 2 s .c o m public String getColumnName(int column) { return headers[column]; } public int getRowCount() { return 3; } public Object getValueAt(int row, int column) { return rows[row][column]; } }; JFrame frame = new JFrame("Scrollless Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(fixedColumnModel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); frame.add(new JScrollPane(table), BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*//from w w w . j a v a 2 s .co m * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this is a global * property and cannot be scoped. It might not be suitable for your * application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }