public final class Header
extends javax.swing.JComponent
implements javax.accessibility.Accessible
The appearance of the header is primarily controlled by its Header.Level
, which you can set using setLevel(Level)
. Headers at any level other than Header.Level.PAGE
will display a disclosure icon, used to expand and collapse the section.
A header is not a container for components. It is intended to be associated with a group of components using a HeaderGroup
, in much the same way ButtonGroup
works for radio buttons. HeaderGroup
automatically takes care of hiding or showing components as the header's disclosure icon is toggled.
A header may have one or more action controls associated with it. Action controls will be displayed in the order in which they are added using the addActionControl( Component )
method.
Modifier and Type | Class and Description |
---|---|
static class |
Header.Level
The visual appearance of a header changes based on its level in the document.
|
static class |
Header.Orientation
The orientation of a header can be either horizontal (default) or vertical.
|
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Header()
Constructs a header.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionControl(javax.swing.Action action)
Adds a control to the toolbar area of this header bound to the specified action.
|
void |
addActionControl(java.awt.Component actionControl)
Adds a control to the toolbar area of this header.
|
void |
addHeaderListener(HeaderListener headerListener)
Adds a listener that will be notified when the header is collapsed or expanded either using the disclosure icon, or programmatically.
|
javax.swing.JButton |
disclosureIcon() |
void |
doLayout() |
protected void |
fireHeaderCollapsed()
Fires the
headerCollapsed event to all HeaderListener s registered using addHeaderListener( HeaderListener ) . |
protected void |
fireHeaderExpanded()
Fires the
headerExpanded event to all HeaderListener s registered using addHeaderListener( HeaderListener ) . |
javax.accessibility.AccessibleContext |
getAccessibleContext() |
java.awt.Color |
getForeground() |
java.lang.String |
getHelpTopicId()
Returns the help topic id for this header.
|
javax.swing.Icon |
getIcon()
Returns the decorative icon for the header.
|
Header.Level |
getLevel()
Returns the level of this header.
|
int |
getMinimumChars()
Returns the minimum number of characters that will be displayed in the label when there is not enough space.
|
java.awt.Dimension |
getMinimumSize() |
Header.Orientation |
getOrientation()
Returns the orientation of this header.
|
java.awt.Dimension |
getPreferredSize() |
java.lang.String |
getRollupStatusText()
Returns the text of the rollup status label.
|
java.lang.String |
getText()
Returns the text of the header.
|
boolean |
isExpandable()
Returns whether this header is expandable.
|
boolean |
isExpanded()
Returns true if the header is currently expanded, false otherwise.
|
protected void |
paintComponent(java.awt.Graphics g) |
void |
removeActionControl(javax.swing.Action action)
Removes a control to the toolbar area of this header that was previously added using
addActionControl(Action) . |
void |
removeActionControl(java.awt.Component actionControl)
Removes a control from the toolbar area of this header.
|
void |
removeHeaderListener(HeaderListener headerListener)
Removes a listener for header expansion that was previously added using the
addHeaderListener( HeaderListener) method. |
void |
setExpandable(boolean expandable)
Sets whether this header is expandable.
|
void |
setExpanded(boolean expanded)
Programmatically sets whether the header is expanded.
|
void |
setForeground(java.awt.Color c) |
void |
setHelpTopicId(java.lang.String helpTopicId)
Sets the help topic id for this header.
|
void |
setIcon(javax.swing.Icon icon)
Sets the header's decorative icon.
|
void |
setLevel(Header.Level level)
Sets the level of this header.
|
void |
setMinimumChars(int minimumChars)
Sets the minimum number of characters that will be displayed in the label when there is not enough space.
|
void |
setName(java.lang.String name)
Override default get name functionality to automatically set derrived name on the disclosure and help icons for testing purposes
|
void |
setOrientation(Header.Orientation orientation)
Sets the orientation of this header.
|
void |
setRollupStatusText(java.lang.String rollupStatusText)
Sets the text of the roll up status label.
|
void |
setText(java.lang.String text)
Sets the text of the header.
|
java.lang.String |
toString() |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public Header()
Page
level header by default.public void setForeground(java.awt.Color c)
setForeground
in class javax.swing.JComponent
public java.awt.Color getForeground()
getForeground
in class java.awt.Component
public javax.swing.JButton disclosureIcon()
public void setName(java.lang.String name)
setName
in class java.awt.Component
name
-public void setMinimumChars(int minimumChars)
minimumChars
- the minimum number of characters to display when there is not enough space to display the whole header text. Must be greater than or equal to zero.java.lang.IllegalArgumentException
- if minimumChars is less than zero.public int getMinimumChars()
public void setOrientation(Header.Orientation orientation)
Header.Orientation.HORIZONTAL
.orientation
- whether this header has a horizontal or vertical orientation. Must not be null.public Header.Orientation getOrientation()
public void setHelpTopicId(java.lang.String helpTopicId)
helpTopicId
- a help topic id. If null, no dynamic help is associated with the header.public java.lang.String getHelpTopicId()
public void addActionControl(java.awt.Component actionControl)
actionControl
- a component to add to the toolbar area of this header. Must not be null.java.lang.NullPointerException
- if actionControl is null.public void addActionControl(javax.swing.Action action)
action
- an action to bind to a button in the toolbar area of this header. Must not be null.java.lang.NullPointerException
- if action is null.public void removeActionControl(javax.swing.Action action)
addActionControl(Action)
.action
- an action to remove from the toolbar.public void removeActionControl(java.awt.Component actionControl)
actionControl
- a component to remove from the toolbar area of this header.public void setText(java.lang.String text)
text
- the text of the header. Must not be null.public java.lang.String getText()
public void setRollupStatusText(java.lang.String rollupStatusText)
rollupStatusText
- text for the rollup status label. If null, or the empty string, the rollup status label will be unconditionally hidden.public java.lang.String getRollupStatusText()
public void setExpandable(boolean expandable)
expandable
- if true, the header can be expanded.public boolean isExpandable()
public void setIcon(javax.swing.Icon icon)
icon
- a decorative icon for the header. If null, the icon will be hidden.public javax.swing.Icon getIcon()
public void setExpanded(boolean expanded)
addHeaderListener( HeaderListener )
method.expanded
- if true, the header will be expanded. Otherwise, it will be collapsed.public boolean isExpanded()
public void addHeaderListener(HeaderListener headerListener)
headerListener
- a listener for header events. Must not be null.public void removeHeaderListener(HeaderListener headerListener)
addHeaderListener( HeaderListener)
method.headerListener
- a listener to remove.protected final void fireHeaderExpanded()
headerExpanded
event to all HeaderListener
s registered using addHeaderListener( HeaderListener )
.protected final void fireHeaderCollapsed()
headerCollapsed
event to all HeaderListener
s registered using addHeaderListener( HeaderListener )
.public void setLevel(Header.Level level)
level
- one of the values of Header.Level
. Must not be null.public Header.Level getLevel()
protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public void doLayout()
doLayout
in class java.awt.Container
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in interface javax.accessibility.Accessible
getAccessibleContext
in class javax.swing.JComponent
public java.lang.String toString()
toString
in class java.awt.Component