public class JXHeader extends JXPanel
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.
BasicHeaderUI uses the following UI defaults:
Modifier and Type | Class and Description |
---|---|
static class |
JXHeader.IconPosition
Specifies desired location of the icon relative to the title/description text.
|
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private String |
description |
private Font |
descriptionFont |
private Color |
descriptionForeground |
private Icon |
icon |
private JXHeader.IconPosition |
iconPosition |
private static long |
serialVersionUID
SerialVersionUID.
|
private String |
title |
private Font |
titleFont |
private Color |
titleForeground |
static String |
uiClassID
JXHeader pluggable UI key HeaderUI
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JXHeader()
Creates a new instance of JXHeader
|
JXHeader(String title,
String description)
Creates a new instance of JXHeader.
|
JXHeader(String title,
String description,
Icon icon)
Creates a new instance of JXHeader.
|
Modifier and Type | Method and Description |
---|---|
String |
getDescription()
Gets the description.
|
Font |
getDescriptionFont()
Gets description font.
|
Color |
getDescriptionForeground()
Gets current description foreground color.
|
Icon |
getIcon()
Gets the icon.
|
JXHeader.IconPosition |
getIconPosition()
Gets current icon position.
|
Dimension |
getPreferredSize() |
String |
getTitle()
Gets the title.
|
Font |
getTitleFont()
Gets title font.
|
Color |
getTitleForeground()
Gets current title foreground color.
|
HeaderUI |
getUI() |
String |
getUIClassID()
Returns the name of the L&F 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 |
setFont(Font font)
Sets new font for both, title and description line of the header.
|
void |
setIcon(Icon icon)
Sets the icon to use for the header.
|
void |
setIconPosition(JXHeader.IconPosition iconPosition)
Sets new Icon position.
|
void |
setTitle(String title)
Sets the title to use.
|
void |
setTitleFont(Font font)
Sets new font for title.
|
void |
setTitleForeground(Color titleForeground)
Sets title foreground color.
|
void |
setUI(HeaderUI ui)
Sets the look and feel (L&F) object that renders this component.
|
void |
updateUI()
Notification from the
UIManager that the L&F has changed. |
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPainterChangeListener, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableHeightHint, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollableWidthHint, installRepaintManager, isInheritAlpha, isPaintBorderInsets, paint, paintComponent, setAlpha, setBackground, setBackgroundPainter, setInheritAlpha, setPaintBorderInsets, setScrollableHeightHint, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth, setScrollableWidthHint, uninstallRepaintManager
getAccessibleContext, paramString, setUI
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, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private static final long serialVersionUID
public static final String uiClassID
private String description
private Font descriptionFont
private Color titleForeground
private Color descriptionForeground
private JXHeader.IconPosition iconPosition
public JXHeader()
public JXHeader(String title, String description)
title
- specifies the title property for this JXHeaderdescription
- specifies the description property for this JXHeaderpublic JXHeader(String title, String description, Icon icon)
title
- specifies the title property for this JXHeaderdescription
- specifies the description property for this JXHeadericon
- specifies the icon property for this JXHeaderpublic void setUI(HeaderUI ui)
ui
- the HeaderUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public String getUIClassID()
getUIClassID
in class JPanel
uiClassID
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager
.updateUI
in class JPanel
JComponent.updateUI()
public void setTitle(String title)
title
- the Title. May be null.public String getTitle()
public void setDescription(String description)
description
- the description. May be null, may be HTML or plain text.public String getDescription()
public void setIcon(Icon icon)
icon
- may be nullpublic void setFont(Font font)
setFont
in class JComponent
JComponent.setFont(java.awt.Font)
public void setTitleFont(Font font)
font
- New title font.public Font getTitleFont()
public void setDescriptionFont(Font font)
font
- New description font.public Font getDescriptionFont()
public Color getTitleForeground()
public void setTitleForeground(Color titleForeground)
titleForeground
- the Color to be used to paint title.public Color getDescriptionForeground()
public void setDescriptionForeground(Color descriptionForeground)
descriptionForeground
- the Color to be used to paint description.public JXHeader.IconPosition getIconPosition()
public void setIconPosition(JXHeader.IconPosition iconPosition)
iconPosition
- new desired icon positiongetIconPosition()
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses