APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.table

public Class JTableHeader

extends JComponent
implements TableColumnModelListener, Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible, javax.swing.event.TableColumnModelListener, java.util.EventListener
Annotations
@SuppressWarnings:serial
Imports
java.awt.Color, .Component, .Cursor, .Dimension, .Font, .FontMetrics, .Point, .Rectangle, java.awt.event.FocusListener, .MouseEvent, java.beans.BeanProperty, .PropertyChangeListener, .Transient, java.io.IOException, .ObjectOutputStream, .Serial, java.util.Locale, javax.accessibility.Accessible, .AccessibleAction, .AccessibleComponent, .AccessibleContext, .AccessibleRole, .AccessibleSelection, .AccessibleState, .AccessibleStateSet, .AccessibleText, .AccessibleValue, javax.swing.JComponent, .JTable, .SwingUtilities, .ToolTipManager, .UIDefaults, .UIManager, javax.swing.event.ChangeEvent, .ListSelectionEvent, .TableColumnModelEvent, .TableColumnModelListener, javax.swing.plaf.TableHeaderUI, sun.awt.AWTAccessor, .AWTAccessor.MouseEventAccessor, sun.swing.table.DefaultTableCellHeaderRenderer

This is the object which manages the header of the JTable.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
Alan Chung, Philip Milne
See Also
javax.swing.JTable

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JTableHeader.AccessibleJTableHeader

This class implements accessibility support for the JTableHeader class.

Field Summary

Modifier and TypeField and Description
protected TableColumnModel
columnModel

The TableColumnModel of the table header.

private TableCellRenderer
defaultRenderer

The default renderer to be used when a TableColumn does not define a headerRenderer.

protected transient TableColumn
draggedColumn

The index of the column being dragged.

protected transient int
draggedDistance

The distance from its original position the column has been dragged.

protected boolean
reorderingAllowed

If true, reordering of columns are allowed by the user; the default is true.

protected boolean
resizingAllowed

If true, resizing of columns are allowed by the user; the default is true.

protected transient TableColumn
resizingColumn

The index of the column being resized.

protected JTable
table

The table for which this object is the header; the default is null.

private static final String
private transient boolean
updateInProgress

Flag to indicate UI update is in progress

protected boolean
updateTableInRealTime

Obsolete as of Java 2 platform v1.3.

Inherited from javax.swing.JComponent:
listenerListTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JTableHeader()

Constructs a JTableHeader with a default TableColumnModel.

public
JTableHeader(TableColumnModel
the column model for the table
cm
)

Constructs a JTableHeader which is initialized with cm as the column model.

Method Summary

Modifier and TypeMethod and Description
public void
columnAdded(TableColumnModelEvent
the event received
e
)

Implements javax.swing.event.TableColumnModelListener.columnAdded.

Invoked when a column is added to the table column model.

public int

Returns:

the index of the column that point lies in, or -1 if it lies out of bounds
columnAtPoint
(Point
if this point lies within a column, the index of that column will be returned; otherwise it is out of bounds and -1 is returned
point
)

Returns the index of the column that point lies in, or -1 if it lies out of bounds.

public void
columnMarginChanged(ChangeEvent
the event received
e
)

Implements javax.swing.event.TableColumnModelListener.columnMarginChanged.

Invoked when a column is moved due to a margin change.

public void
columnMoved(TableColumnModelEvent
the event received
e
)

Implements javax.swing.event.TableColumnModelListener.columnMoved.

Invoked when a column is repositioned.

public void
columnRemoved(TableColumnModelEvent
the event received
e
)

Implements javax.swing.event.TableColumnModelListener.columnRemoved.

Invoked when a column is removed from the table column model.

public void
columnSelectionChanged(ListSelectionEvent
the event received
e
)

Implements javax.swing.event.TableColumnModelListener.columnSelectionChanged.

Invoked when the selection model of the TableColumnModel is changed.

protected TableColumnModel

Returns:

the default column model object
createDefaultColumnModel
()

Returns the default column model object which is a DefaultTableColumnModel.

protected TableCellRenderer

Returns:

the default table column renderer
createDefaultRenderer
()

Returns a default renderer to be used when no header renderer is defined by a TableColumn.

public AccessibleContext

Returns:

an AccessibleJTableHeader that serves as the AccessibleContext of this JTableHeader
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JTableHeader.

public TableColumnModel

Returns:

the columnModel property
getColumnModel
()

Returns the TableColumnModel that contains all column information of this table header.

public TableCellRenderer

Returns:

the default renderer
getDefaultRenderer
()

Returns the default renderer used when no headerRenderer is defined by a TableColumn.

public TableColumn

Returns:

the dragged column, if a drag is in process, otherwise returns null
getDraggedColumn
()

Returns the dragged column, if and only if, a drag is in process, otherwise returns null.

public int

Returns:

the column's horizontal distance from its original position, if a drag is in process, otherwise the return value is meaningless
getDraggedDistance
()

Returns the column's horizontal distance from its original position, if and only if, a drag is in process.

public Rectangle

Returns:

the rectangle containing the header tile at column
getHeaderRect
(int
index of the column
column
)

Returns the rectangle containing the header tile at column.

public Dimension

Returns:

the size
getPreferredSize
()

Overrides javax.swing.JComponent.getPreferredSize.

Returns the preferred size of the table header.

public boolean

Returns:

the reorderingAllowed property
getReorderingAllowed
()

Returns true if the user is allowed to rearrange columns by dragging their headers, false otherwise.

public boolean

Returns:

the resizingAllowed property
getResizingAllowed
()

Returns true if the user is allowed to resize columns by dragging between their headers, false otherwise.

public TableColumn

Returns:

the resizing column, if a resize is in process, otherwise returns null
getResizingColumn
()

Returns the resizing column.

public JTable

Returns:

the table property
getTable
()

Returns the table associated with this header.

public String

Returns:

the tool tip for this component
getToolTipText
(MouseEvent
the location of the event identifies the proper renderer and, therefore, the proper tip
event
)

Overrides javax.swing.JComponent.getToolTipText.

Allows the renderer's tips to be used if there is text set.

public TableHeaderUI

Returns:

the TableHeaderUI object that renders this component
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the look and feel (L&F) object that renders this component.

public String

Returns:

the string "TableHeaderUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.

public boolean

Returns:

true if the table updates in real time
getUpdateTableInRealTime
()

Obsolete as of Java 2 platform v1.3.

private int
protected void
initializeLocalVars()

Initializes the local variables and properties with default values.

protected String

Returns:

a string representation of this JTableHeader
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JTableHeader.

public void
resizeAndRepaint()

Sizes the header and marks it as needing display.

public void
setColumnModel(TableColumnModel
the new data source for this table
columnModel
)

Sets the column model for this table to newModel and registers for listener notifications from the new column model.

public void
setDefaultRenderer(TableCellRenderer
the default renderer
defaultRenderer
)

Sets the default renderer to be used when no headerRenderer is defined by a TableColumn.

public void
setDraggedColumn(TableColumn
the column being dragged, or null if no column is being dragged
aColumn
)

Sets the header's draggedColumn to aColumn.

public void
setDraggedDistance(int
the distance dragged
distance
)

Sets the header's draggedDistance to distance.

public void
setReorderingAllowed(boolean
true if the table view should allow reordering; otherwise false
reorderingAllowed
)

Sets whether the user can drag column headers to reorder columns.

public void
setResizingAllowed(boolean
true if table view should allow resizing
resizingAllowed
)

Sets whether the user can resize columns by dragging between headers.

public void
setResizingColumn(TableColumn
the column being resized, or null if no column is being resized
aColumn
)

Sets the header's resizingColumn to aColumn.

public void
setTable(JTable
the new table
table
)

Sets the table associated with this header.

public void
setUI(TableHeaderUI
the TableHeaderUI L&F object
ui
)

Sets the look and feel (L&F) object that renders this component.

public void
setUpdateTableInRealTime(boolean
true if tableView should update the body of the table in real time
flag
)

Obsolete as of Java 2 platform v1.3.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Notification from the UIManager that the look and feel (L&F) has changed.

Inherited from javax.swing.JComponent:
addAncestorListeneraddNotifyaddVetoableChangeListenercomputeVisibleRectcontainscreateToolTipdisableenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintBorderpaintChildrenpaintComponentpaintImmediatelypaintImmediatelyprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatescrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetVerifyInputWhenFocusTargetsetVisibleunregisterKeyboardActionupdate