Java JTable Header layoutHeaders(JTable p_Table)

Here you can find the source of layoutHeaders(JTable p_Table)

Description

layout Headers

License

Open Source License

Declaration

public static void layoutHeaders(JTable p_Table) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import javax.swing.JTable;

import javax.swing.table.TableColumn;

public class Main {
    public static void layoutHeaders(JTable p_Table) {
        int column = 0;
        for (java.util.Enumeration columns = p_Table.getTableHeader().getColumnModel().getColumns(); columns
                .hasMoreElements(); column++) {
            TableColumn c = (TableColumn) columns.nextElement();
            Component component = c.getHeaderRenderer().getTableCellRendererComponent(p_Table, c.getHeaderValue(),
                    false, false, -1, column);
            c.setPreferredWidth(Math.max(c.getPreferredWidth(), component.getPreferredSize().width));
        }//  w w  w.  j  av  a 2 s.com
    }
}

Related

  1. getTableHeaderBackground()
  2. getTableHeaderColor()
  3. headerString(JTable t)
  4. isColumnSelected(JTableHeader tableHeader, int columnModelIndex)
  5. isRowHeaderVisible(JTable table)
  6. makeHeaderFillEmptySpace(JTable table)
  7. makeTableHeadersCentered(final JTable table, final boolean dataColsAlso)
  8. modifyTableHeader(JTableHeader head, Vector columnNames)
  9. paintHeader(Graphics graphics, JTable table, int x, int width)