oreilly java swing : JTable 之 JTableHeader

15.3.9 The JTableHeader Class

The JTableHeader class is an extension of JComponent and serves as the header component for tables. It not only dictates the basic color and font used for the header, but also the resizability and relocatability of the columns in the table. If you have an appropriate renderer for the header, you can also enable tooltips for the header. An example of custom renderers appears in Chapter 16.

15.3.9.1 Properties

The JTableHeader class has the properties listed in Table 15-14.

Table 15-14. JTableHeader properties

Property

Data type

get

is

set

Default value

accessibleContexto

AccessibleContext

·

JTableHeader.AccessibleJTableHeader( )

columnModel

TableColumnModel

·

·

DefaultColumnModel( )

draggedColumn

TableColumn

·

·

null

draggedDistance

int

·

·

0

opaqueo

boolean

·

·

true

reorderingAllowed

boolean

·

·

true

resizingAllowed

boolean

·

·

true

resizingColumn

TableColumn

·

·

null

table

JTable

·

·

null

UIb

TableHeaderUI

·

·

From L&F

UIClassIDo

String

·

"TableHeaderUI"

updateTableInRealTime

boolean

·

·

true

bbound, ooverridden

See also properties from the JComponent class (Table 3-6).

The columnModel property is the TableColumnModel in place for the header. This is normally set through the constructor during the JTable initializeLocalVars( ) call. The draggedColumn and resizingColumn properties return the TableColumn object that the user has moved or resized. You can control whether the user is allowed to move or resize columns using the reorderingAllowed and resizingAllowed properties. The updateTableInRealTime property dictates whether the column being moved or resized is visually updated during the move or after. If this property is false, only the column headers move until the action is complete, and then the table is updated. The table property represents the companion table for the header.


你可能感兴趣的:(java swing)