Package org.jdesktop.swingx
Class JXHeader
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jdesktop.swingx.JXPanel
org.jdesktop.swingx.JXHeader
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,Scrollable
JXHeader
is a simple component consisting of a title, a description,
and an icon. An example of such a component can be seen on
Romain Guys ProgX website
JXHeader
is a simple component that is also sufficiently
configurable to be usable. The description area
accepts HTML conforming to version 3.2 of the HTML standard. The icon, title,
and description are all configurable. JXHeader
itself extends
JXPanel
, providing translucency and painting delegates.
If I were to reconstruct the ui shown in the above screenshot, I might
do so like this:
JXHeader header = new JXHeader();
header.setTitle("Timing Framework Spline Editor");
header.setDescription("Drag control points in the display to change the " +
"shape of the spline\n" +
"Click the Copy Code button to generate the corresponding Java code.");
Icon icon = new ImageIcon(getClass().getResource("tools.png"));
header.setIcon(icon);
Note: The HTML support doesn't exist yet. The UI delegate needs to discover whether
the text supplied is HTML or not, and change the content type of the editor pane
being used. The problem is that if "text/html" is always used, the font is wrong.
This same situation will be found in other parts of the code (JXErrorPane, for instance),
so this needs to be dealt with.
Defaults
BasicHeaderUI uses the following UI defaults:
- Header.defaultIcon: The default icon to use when creating a new JXHeader.
- Author:
- rbair, rah003
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Specifies desired location of the icon relative to the title/description text.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the description.Gets description font.Gets current description foreground color.getIcon()
Gets the icon.Gets current icon position.getTitle()
Gets the title.Gets title font.Gets current title foreground color.getUI()
Returns the name of the LaF class that renders this component.void
setDescription
(String description) Sets the description for this header.void
setDescriptionFont
(Font font) Sets font for the description line of header.void
setDescriptionForeground
(Color descriptionForeground) Sets description foreground color.void
Sets new font for both, title and description line of the header.void
Sets the icon to use for the header.void
setIconPosition
(JXHeader.IconPosition iconPosition) Sets new Icon position.void
Sets the title to use.void
setTitleFont
(Font font) Sets new font for title.void
setTitleForeground
(Color titleForeground) Sets title foreground color.void
Sets the look and feel (LaF) object that renders this component.void
updateUI()
Notification from theUIManager
that the LaF has changed.Methods inherited from class org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPainterChangeListener, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableHeightHint, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollableWidthHint, isAlpha, isInheritAlpha, isOpaque, isOpaquePatch, isPaintBorderInsets, isPaintingBackground, isPaintingOrigin, isPatch, isTransparentBackground, paint, paintComponent, paintComponentPatch, setAlpha, setBackgroundPainter, setInheritAlpha, setOpaque, setOpaquePatch, setPaintBorderInsets, setScrollableHeightHint, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth, setScrollableWidthHint
Methods inherited from class javax.swing.JPanel
getAccessibleContext, paramString, setUI
Methods inherited from class javax.swing.JComponent
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paintImmediately, 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, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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
Methods inherited from class java.awt.Component
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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
uiClassID
JXHeader pluggable UI key HeaderUI- See Also:
-
-
Constructor Details
-
JXHeader
public JXHeader()Creates a new instance of JXHeader -
JXHeader
Creates a new instance of JXHeader. PropertyChangeEvents are fired when the title and description properties are set.- Parameters:
title
- specifies the title property for this JXHeaderdescription
- specifies the description property for this JXHeader
-
JXHeader
Creates a new instance of JXHeader. PropertyChangeEvents are fired when the title and description properties are set.- Parameters:
title
- specifies the title property for this JXHeaderdescription
- specifies the description property for this JXHeadericon
- specifies the icon property for this JXHeader
-
-
Method Details
-
getUI
-
setUI
Sets the look and feel (LaF) object that renders this component.- Parameters:
ui
- the HeaderUI LaF object- See Also:
-
getUIClassID
Returns the name of the LaF class that renders this component.- Overrides:
getUIClassID
in classJPanel
- Returns:
- the string
uiClassID
- See Also:
-
updateUI
public void updateUI()Notification from theUIManager
that the LaF has changed. Replaces the current UI object with the latest version from theUIManager
. -
setTitle
Sets the title to use. This may be either plain text, or a simplified version of HTML, as JLabel would use.- Parameters:
title
- the Title. May be null.
-
getTitle
Gets the title. This may use HTML, such as that supported by JLabel (version 3.2 of the HTML spec).- Returns:
- the title. May be null.
-
setDescription
Sets the description for this header. This may use HTML, such as that supported by JLabel (version 3.2 of the HTML spec).- Parameters:
description
- the description. May be null, may be HTML or plain text.
-
getDescription
Gets the description.- Returns:
- description
-
setIcon
Sets the icon to use for the header. It is generally recommended that this be an image 64x64 pixels in size, and that the icon have no gaps at the top.- Parameters:
icon
- may be null
-
getIcon
Gets the icon.- Returns:
- the Icon being used. May be null.
-
setFont
Sets new font for both, title and description line of the header.- Overrides:
setFont
in classJComponent
- See Also:
-
setTitleFont
Sets new font for title.- Parameters:
font
- New title font.
-
getTitleFont
Gets title font.- Returns:
- the Font being used. May be null.
-
setDescriptionFont
Sets font for the description line of header.- Parameters:
font
- New description font.
-
getDescriptionFont
Gets description font.- Returns:
- the Font being used. May be null.
-
getTitleForeground
Gets current title foreground color.- Returns:
- the Color used to paint title. May be null.
-
setTitleForeground
Sets title foreground color.- Parameters:
titleForeground
- the Color to be used to paint title.
-
getDescriptionForeground
Gets current description foreground color.- Returns:
- the Color used to paint description. May be null.
-
setDescriptionForeground
Sets description foreground color.- Parameters:
descriptionForeground
- the Color to be used to paint description.
-
getIconPosition
Gets current icon position. Default is RIGHT.- Returns:
- Current Icon position.
-
setIconPosition
Sets new Icon position. Position is relative to the text. Default value is RIGHT.- Parameters:
iconPosition
- new desired icon position- See Also:
-
getPreferredSize
- Overrides:
getPreferredSize
in classJComponent
-