Java Reference
In-Depth Information
You rarely need to work with the JTableHeader directly. Nevertheless, you can configure some
characteristics of column headers.
Creating a JTableHeader
The JTableHeader has two constructors. One uses the default TableColumnModel , whereas the
other explicitly specifies the model.
public JTableHeader()
JComponent headerComponent = new JTableHeader()
public JTableHeader(TableColumnModel columnModel)
JComponent headerComponent = new JTableHeader(aColumnModel)
JTableHeader Properties
As Table 18-11 shows, the JTableHeader has ten different properties. These properties allow
you to configure what the user can do with a particular column header or how the column
header is shown.
Table 18-11. JTableHeader Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
columnModel
TableColumnModel
Read-write bound
draggedColumn
TableColumn
Read-write
draggedDistance
int
Read-write
reorderingAllowed
boolean
Read-write bound
resizingAllowed
boolean
Read-write bound
resizingColumn
TableColumn
Read-write
table
JTable
Read-write bound
UI
TableHeaderUI
Read-write
UIClassID
String
Read-only
Using Tooltips in Table Headers
By default, if you set tooltip text for the table header, all of the column headers will share the
same tooltip text. To specify a tooltip for a given column, you need to create or get the renderer,
and then set the tooltip for the renderer. This is true for the individual cells, too. Figure 18-12
shows how the results of this customization would appear.
Search WWH ::




Custom Search