Java Utililty Methods JTable Column Header Width

List of utility methods to do JTable Column Header Width

Description

The list of methods to do JTable Column Header Width are organized into topic(s).

Method

intgetPreferredColumnHeaderWidth(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;
voidsetOptimalHeaderWidth(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);
...