Open GoogleCodeExporter opened 9 years ago
Make a working version of: private void initColumnSizes(JTable table) { MyTableModel model = (MyTableModel)table.getModel(); TableColumn column = null; Component comp = null; int headerWidth = 0; int cellWidth = 0; Object[] longValues = model.longValues; TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); comp = headerRenderer.getTableCellRendererComponent( null, column.getHeaderValue(), false, false, 0, 0); headerWidth = comp.getPreferredSize().width; comp = table.getDefaultRenderer(model.getColumnClass(i)). getTableCellRendererComponent( table, longValues[i], false, false, 0, i); cellWidth = comp.getPreferredSize().width; if (DEBUG) { System.out.println("Initializing width of column " + i + ". " + "headerWidth = " + headerWidth + "; cellWidth = " + cellWidth); } column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } } Expect the method do change the column's size, but it don't.
Original issue reported on code.google.com by brito....@gmail.com on 19 Mar 2010 at 3:27
brito....@gmail.com
Original issue reported on code.google.com by
brito....@gmail.com
on 19 Mar 2010 at 3:27