List of utility methods to do JTable Column Header Width
int | getPreferredColumnHeaderWidth(JTable table, TableColumn col) get Preferred Column Header Width TableCellRenderer renderer = col.getHeaderRenderer(); if (renderer == null) return 0; Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0); return comp.getPreferredSize().width; |
void | setOptimalHeaderWidth(JTable table, int col) sets the optimal header width for the given column. int width; TableColumn column; JTableHeader header; if ((col >= 0) && (col < table.getColumnModel().getColumnCount())) { width = calcHeaderWidth(table, col); if (width >= 0) { header = table.getTableHeader(); column = table.getColumnModel().getColumn(col); ... |