Package com.jidesoft.dialog
Class BannerPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.jidesoft.dialog.BannerPanel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
BannerPanel
is a panel that can show title, subtitle and icon with title on top, subtitle on the bottom
and icon on the left. You can use ImageIcon as the icon but you can also use your own component as the icon component
by using setIconComponent(javax.swing.JComponent)
.
BannerPanel
can be placed on top of any dialog or any panel to show some help information or display a
product logo.- See Also:
-
Nested Class Summary
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
FieldsModifier and TypeFieldDescriptionprotected Paint
protected Color
protected boolean
protected PropertyChangeListener
protected Color
protected String
Subtitle or description of the banner panel.protected Color
protected Font
protected int
protected String
Title of the banner panel.protected Color
protected Font
protected ImageIcon
Icon for the banner panel.static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields 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
ConstructorsConstructorDescriptionCreates an empty BannerPanel.BannerPanel
(String title) Creates a BannerPanel with title and subtitle.BannerPanel
(String title, String subtitle) Creates a BannerPanel with title and subtitle.BannerPanel
(String title, String subtitle, ImageIcon titleIcon) Creates a BannerPanel with title, subtitle and icon.BannerPanel
(String title, String subtitle, JComponent iconComponent) Creates a BannerPanel with title, subtitle and component. -
Method Summary
Modifier and TypeMethodDescriptionprotected JComponent
Creates the subtitle label.Gets the Paint used to paint the background of the BannerPanel.Gets the icon component.Gets the subtitle.Gets the subtitle color.Gets the font of the subtitle.int
Gets the subtitle indent.Gets the component for the subtitle.getTitle()
Gets the title.Gets the title color.Gets the font of the title.Gets the title icon.int
Gets the title icon location.Gets the component for the title.boolean
void
protected void
Paints the background.protected ImageIcon
prepareTitleIcon
(ImageIcon icon) Prepares the title icon.void
setBackground
(Color bg) void
setBackgroundPaint
(Paint backgroundPaint) Sets the Paint used to paint the background of the BannerPanel.void
setEndColor
(Color endColor) void
setForeground
(Color fg) void
setGradientPaint
(Color startColor, Color endColor, boolean isVertical) This method allows you to use gradient background without usingsetBackgroundPaint(java.awt.Paint)
method.void
setIconComponent
(JComponent iconComponent) Sets the icon component.void
setStartColor
(Color startColor) void
setSubtitle
(String subtitle) Sets the subtitle.void
setSubTitleColor
(Color subTitleColor) Sets the subtitle color.void
setSubTitleFont
(Font subTitleFont) Sets the font for the subtitle.void
setSubTitleIndent
(int subTitleIndent) Sets the subtitle indent.void
Sets the title.void
setTitleColor
(Color titleColor) Sets the title color.void
setTitleFont
(Font titleFont) Sets the font for the title.void
setTitleIcon
(ImageIcon titleIcon) Sets the title icon.void
setTitleIconLocation
(int titleIconLocation) Sets the title icon location.void
setVertical
(boolean vertical) Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, getPreferredSize, 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, paint, 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, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, 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
-
_title
Title of the banner panel. -
_subtitle
Subtitle or description of the banner panel. -
_titleIcon
Icon for the banner panel. -
TITLE_PROPERTY
- See Also:
-
SUBTITLE_PROPERTY
- See Also:
-
ICON_PROPERTY
- See Also:
-
ICON_COMPONENT_PROPERTY
- See Also:
-
PROPERTY_TITLE_FONT
- See Also:
-
PROPERTY_SUBTITLE_FONT
- See Also:
-
PROPERTY_TITLE_ICON_LOCATION
- See Also:
-
_subTitleIndent
protected int _subTitleIndent -
_titleFont
-
_titleColor
-
_subTitleFont
-
_subTitleColor
-
_backgroundPaint
-
_propertyListener
-
_startColor
-
_endColor
-
_isVertical
protected boolean _isVertical -
_textPanel
-
-
Constructor Details
-
BannerPanel
public BannerPanel()Creates an empty BannerPanel. -
BannerPanel
Creates a BannerPanel with title and subtitle.- Parameters:
title
- the title.
-
BannerPanel
Creates a BannerPanel with title and subtitle.- Parameters:
title
- the title.subtitle
- the sub title.
-
BannerPanel
Creates a BannerPanel with title, subtitle and icon.- Parameters:
title
- the title.subtitle
- the sub title.titleIcon
- the icon.
-
BannerPanel
Creates a BannerPanel with title, subtitle and component.- Parameters:
title
- the title.subtitle
- the sub title.iconComponent
- the icon component. It will appear where the icon is if using constructorBannerPanel(String,String,javax.swing.ImageIcon)
.
-
-
Method Details
-
lazyInitialize
public void lazyInitialize() -
createSubtitleLabel
Creates the subtitle label.- Returns:
- a MultilineLabel instance by default.
- Since:
- 3.4.2
-
prepareTitleIcon
Prepares the title icon.- Parameters:
icon
- the input icon fro setTitleIcon(icon).- Returns:
- the image icon after processing. By default it will return the same image icon. Subclass can override it to scale the image or do other processing.
-
getBackgroundPaint
Gets the Paint used to paint the background of the BannerPanel.- Returns:
- the Paint used to paint the background.
-
setBackgroundPaint
Sets the Paint used to paint the background of the BannerPanel. User can set the paint to a gradient paint to make the BannerPanel looks attractive.- Parameters:
backgroundPaint
- the background paint.
-
setGradientPaint
This method allows you to use gradient background without usingsetBackgroundPaint(java.awt.Paint)
method. You can use GradientPaint to do the same thing. However if you use this method, it will use fast gradient paint defined in JideSwingUtilities to do the painting.- Parameters:
startColor
- start color of the gradientendColor
- end color of the gradientisVertical
- vertical or not
-
paintComponent
Paints the background.- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- the Graphics
-
getTitle
Gets the title.- Returns:
- the title of the banner panel.
-
setTitle
Sets the title.- Parameters:
title
- the new title.
-
getSubtitle
Gets the subtitle.- Returns:
- the subtitle
-
setSubtitle
Sets the subtitle.- Parameters:
subtitle
- the new subtitle.
-
getTitleIcon
Gets the title icon.- Returns:
- the title icon
-
setTitleIcon
Sets the title icon.- Parameters:
titleIcon
- the new titleIcon.
-
getIconComponent
Gets the icon component. If you use constructorBannerPanel(String,String,javax.swing.ImageIcon)
, the icon component will be a JLabel with the icon in the 3rd parameter. If you use the constructorBannerPanel(String,String,javax.swing.JComponent)
, it will return the component as in the 3rd parameter.- Returns:
- the icon component
-
setIconComponent
Sets the icon component.- Parameters:
iconComponent
- the component that is used as the icon.
-
getSubTitleFont
Gets the font of the subtitle.- Returns:
- the font of the subtitle
-
setSubTitleFont
Sets the font for the subtitle.- Parameters:
subTitleFont
- the new font for the subtitle.
-
getTitleFont
Gets the font of the title.- Returns:
- the font of the title
-
setTitleFont
Sets the font for the title.- Parameters:
titleFont
- the new font for the title.
-
getSubTitleIndent
public int getSubTitleIndent()Gets the subtitle indent.- Returns:
- the subtitle indent.
-
setSubTitleIndent
public void setSubTitleIndent(int subTitleIndent) Sets the subtitle indent. Subtitle is always behind the title. The indent will decide how behind. It's in pixels.- Parameters:
subTitleIndent
- the new index.
-
getTitleColor
Gets the title color.- Returns:
- the color of title.
-
setTitleColor
Sets the title color.- Parameters:
titleColor
- the text color for the title.
-
getSubTitleColor
Gets the subtitle color.- Returns:
- the color of subtitle.
-
setSubTitleColor
Sets the subtitle color.- Parameters:
subTitleColor
- the text color for the subtitle.
-
setBackground
- Overrides:
setBackground
in classJComponent
-
setForeground
- Overrides:
setForeground
in classJComponent
-
getStartColor
-
setStartColor
-
getEndColor
-
setEndColor
-
isVertical
public boolean isVertical() -
setVertical
public void setVertical(boolean vertical) -
getTitleIconLocation
public int getTitleIconLocation()Gets the title icon location. By default, it is SwingConstants.TRAILING.- Returns:
- the title icon location.
-
setTitleIconLocation
public void setTitleIconLocation(int titleIconLocation) Sets the title icon location. By default the title icon is added a border layout using BorderLayout.AFTER_LINE_ENDS. However you can use this method to decide where to add. Valid values are SwingContants.EAST and SwingContants.WEST as well as SwingContants.LEADING and SwingContants.TRAILING considering the case of both RTL and LTR.- Parameters:
titleIconLocation
- the title icon location.
-
getTitleLabel
Gets the component for the title.- Returns:
- a JLabel.
-
getSubtitleLabel
Gets the component for the subtitle.- Returns:
- a MultilineLabel by default
-