Class BannerPanel

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public class BannerPanel
    extends javax.swing.JPanel
    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:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.awt.Paint _backgroundPaint  
      protected java.awt.Color _endColor  
      protected boolean _isVertical  
      protected java.beans.PropertyChangeListener _propertyListener  
      protected java.awt.Color _startColor  
      protected java.lang.String _subtitle
      Subtitle or description of the banner panel.
      protected java.awt.Color _subTitleColor  
      protected java.awt.Font _subTitleFont  
      protected int _subTitleIndent  
      javax.swing.JPanel _textPanel  
      protected java.lang.String _title
      Title of the banner panel.
      protected java.awt.Color _titleColor  
      protected java.awt.Font _titleFont  
      protected javax.swing.ImageIcon _titleIcon
      Icon for the banner panel.
      static java.lang.String ICON_COMPONENT_PROPERTY  
      static java.lang.String ICON_PROPERTY  
      static java.lang.String PROPERTY_SUBTITLE_FONT  
      static java.lang.String PROPERTY_TITLE_FONT  
      static java.lang.String PROPERTY_TITLE_ICON_LOCATION  
      static java.lang.String SUBTITLE_PROPERTY  
      static java.lang.String TITLE_PROPERTY  
      • 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

      Constructors 
      Constructor Description
      BannerPanel()
      Creates an empty BannerPanel.
      BannerPanel​(java.lang.String title)
      Creates a BannerPanel with title and subtitle.
      BannerPanel​(java.lang.String title, java.lang.String subtitle)
      Creates a BannerPanel with title and subtitle.
      BannerPanel​(java.lang.String title, java.lang.String subtitle, javax.swing.ImageIcon titleIcon)
      Creates a BannerPanel with title, subtitle and icon.
      BannerPanel​(java.lang.String title, java.lang.String subtitle, javax.swing.JComponent iconComponent)
      Creates a BannerPanel with title, subtitle and component.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected javax.swing.JComponent createSubtitleLabel()
      Creates the subtitle label.
      java.awt.Paint getBackgroundPaint()
      Gets the Paint used to paint the background of the BannerPanel.
      java.awt.Color getEndColor()  
      javax.swing.JComponent getIconComponent()
      Gets the icon component.
      java.awt.Color getStartColor()  
      java.lang.String getSubtitle()
      Gets the subtitle.
      java.awt.Color getSubTitleColor()
      Gets the subtitle color.
      java.awt.Font getSubTitleFont()
      Gets the font of the subtitle.
      int getSubTitleIndent()
      Gets the subtitle indent.
      javax.swing.JComponent getSubtitleLabel()
      Gets the component for the subtitle.
      java.lang.String getTitle()
      Gets the title.
      java.awt.Color getTitleColor()
      Gets the title color.
      java.awt.Font getTitleFont()
      Gets the font of the title.
      javax.swing.ImageIcon getTitleIcon()
      Gets the title icon.
      int getTitleIconLocation()
      Gets the title icon location.
      javax.swing.JComponent getTitleLabel()
      Gets the component for the title.
      boolean isVertical()  
      void lazyInitialize()  
      protected void paintComponent​(java.awt.Graphics g)
      Paints the background.
      protected javax.swing.ImageIcon prepareTitleIcon​(javax.swing.ImageIcon icon)
      Prepares the title icon.
      void setBackground​(java.awt.Color bg)  
      void setBackgroundPaint​(java.awt.Paint backgroundPaint)
      Sets the Paint used to paint the background of the BannerPanel.
      void setEndColor​(java.awt.Color endColor)  
      void setForeground​(java.awt.Color fg)  
      void setGradientPaint​(java.awt.Color startColor, java.awt.Color endColor, boolean isVertical)
      This method allows you to use gradient background without using setBackgroundPaint(java.awt.Paint) method.
      void setIconComponent​(javax.swing.JComponent iconComponent)
      Sets the icon component.
      void setStartColor​(java.awt.Color startColor)  
      void setSubtitle​(java.lang.String subtitle)
      Sets the subtitle.
      void setSubTitleColor​(java.awt.Color subTitleColor)
      Sets the subtitle color.
      void setSubTitleFont​(java.awt.Font subTitleFont)
      Sets the font for the subtitle.
      void setSubTitleIndent​(int subTitleIndent)
      Sets the subtitle indent.
      void setTitle​(java.lang.String title)
      Sets the title.
      void setTitleColor​(java.awt.Color titleColor)
      Sets the title color.
      void setTitleFont​(java.awt.Font titleFont)
      Sets the font for the title.
      void setTitleIcon​(javax.swing.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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _title

        protected java.lang.String _title
        Title of the banner panel.
      • _subtitle

        protected java.lang.String _subtitle
        Subtitle or description of the banner panel.
      • _titleIcon

        protected javax.swing.ImageIcon _titleIcon
        Icon for the banner panel.
      • SUBTITLE_PROPERTY

        public static final java.lang.String SUBTITLE_PROPERTY
        See Also:
        Constant Field Values
      • ICON_COMPONENT_PROPERTY

        public static final java.lang.String ICON_COMPONENT_PROPERTY
        See Also:
        Constant Field Values
      • PROPERTY_TITLE_FONT

        public static final java.lang.String PROPERTY_TITLE_FONT
        See Also:
        Constant Field Values
      • PROPERTY_SUBTITLE_FONT

        public static final java.lang.String PROPERTY_SUBTITLE_FONT
        See Also:
        Constant Field Values
      • PROPERTY_TITLE_ICON_LOCATION

        public static final java.lang.String PROPERTY_TITLE_ICON_LOCATION
        See Also:
        Constant Field Values
      • _subTitleIndent

        protected int _subTitleIndent
      • _titleFont

        protected java.awt.Font _titleFont
      • _titleColor

        protected java.awt.Color _titleColor
      • _subTitleFont

        protected java.awt.Font _subTitleFont
      • _subTitleColor

        protected java.awt.Color _subTitleColor
      • _backgroundPaint

        protected java.awt.Paint _backgroundPaint
      • _propertyListener

        protected java.beans.PropertyChangeListener _propertyListener
      • _startColor

        protected java.awt.Color _startColor
      • _endColor

        protected java.awt.Color _endColor
      • _isVertical

        protected boolean _isVertical
      • _textPanel

        public javax.swing.JPanel _textPanel
    • Constructor Detail

      • BannerPanel

        public BannerPanel()
        Creates an empty BannerPanel.
      • BannerPanel

        public BannerPanel​(java.lang.String title)
        Creates a BannerPanel with title and subtitle.
        Parameters:
        title - the title.
      • BannerPanel

        public BannerPanel​(java.lang.String title,
                           java.lang.String subtitle)
        Creates a BannerPanel with title and subtitle.
        Parameters:
        title - the title.
        subtitle - the sub title.
      • BannerPanel

        public BannerPanel​(java.lang.String title,
                           java.lang.String subtitle,
                           javax.swing.ImageIcon titleIcon)
        Creates a BannerPanel with title, subtitle and icon.
        Parameters:
        title - the title.
        subtitle - the sub title.
        titleIcon - the icon.
      • BannerPanel

        public BannerPanel​(java.lang.String title,
                           java.lang.String subtitle,
                           javax.swing.JComponent iconComponent)
        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 constructor BannerPanel(String,String,javax.swing.ImageIcon).
    • Method Detail

      • lazyInitialize

        public void lazyInitialize()
      • createSubtitleLabel

        protected javax.swing.JComponent createSubtitleLabel()
        Creates the subtitle label.
        Returns:
        a MultilineLabel instance by default.
        Since:
        3.4.2
      • prepareTitleIcon

        protected javax.swing.ImageIcon prepareTitleIcon​(javax.swing.ImageIcon icon)
        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

        public java.awt.Paint getBackgroundPaint()
        Gets the Paint used to paint the background of the BannerPanel.
        Returns:
        the Paint used to paint the background.
      • setBackgroundPaint

        public void setBackgroundPaint​(java.awt.Paint backgroundPaint)
        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

        public void setGradientPaint​(java.awt.Color startColor,
                                     java.awt.Color endColor,
                                     boolean isVertical)
        This method allows you to use gradient background without using setBackgroundPaint(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 gradient
        endColor - end color of the gradient
        isVertical - vertical or not
      • paintComponent

        protected void paintComponent​(java.awt.Graphics g)
        Paints the background.
        Overrides:
        paintComponent in class javax.swing.JComponent
        Parameters:
        g - the Graphics
      • getTitle

        public java.lang.String getTitle()
        Gets the title.
        Returns:
        the title of the banner panel.
      • setTitle

        public void setTitle​(java.lang.String title)
        Sets the title.
        Parameters:
        title - the new title.
      • getSubtitle

        public java.lang.String getSubtitle()
        Gets the subtitle.
        Returns:
        the subtitle
      • setSubtitle

        public void setSubtitle​(java.lang.String subtitle)
        Sets the subtitle.
        Parameters:
        subtitle - the new subtitle.
      • getTitleIcon

        public javax.swing.ImageIcon getTitleIcon()
        Gets the title icon.
        Returns:
        the title icon
      • setTitleIcon

        public void setTitleIcon​(javax.swing.ImageIcon titleIcon)
        Sets the title icon.
        Parameters:
        titleIcon - the new titleIcon.
      • setIconComponent

        public void setIconComponent​(javax.swing.JComponent iconComponent)
        Sets the icon component.
        Parameters:
        iconComponent - the component that is used as the icon.
      • getSubTitleFont

        public java.awt.Font getSubTitleFont()
        Gets the font of the subtitle.
        Returns:
        the font of the subtitle
      • setSubTitleFont

        public void setSubTitleFont​(java.awt.Font subTitleFont)
        Sets the font for the subtitle.
        Parameters:
        subTitleFont - the new font for the subtitle.
      • getTitleFont

        public java.awt.Font getTitleFont()
        Gets the font of the title.
        Returns:
        the font of the title
      • setTitleFont

        public void setTitleFont​(java.awt.Font titleFont)
        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

        public java.awt.Color getTitleColor()
        Gets the title color.
        Returns:
        the color of title.
      • setTitleColor

        public void setTitleColor​(java.awt.Color titleColor)
        Sets the title color.
        Parameters:
        titleColor - the text color for the title.
      • getSubTitleColor

        public java.awt.Color getSubTitleColor()
        Gets the subtitle color.
        Returns:
        the color of subtitle.
      • setSubTitleColor

        public void setSubTitleColor​(java.awt.Color subTitleColor)
        Sets the subtitle color.
        Parameters:
        subTitleColor - the text color for the subtitle.
      • setBackground

        public void setBackground​(java.awt.Color bg)
        Overrides:
        setBackground in class javax.swing.JComponent
      • setForeground

        public void setForeground​(java.awt.Color fg)
        Overrides:
        setForeground in class javax.swing.JComponent
      • getStartColor

        public java.awt.Color getStartColor()
      • setStartColor

        public void setStartColor​(java.awt.Color startColor)
      • getEndColor

        public java.awt.Color getEndColor()
      • setEndColor

        public void setEndColor​(java.awt.Color endColor)
      • 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

        public javax.swing.JComponent getTitleLabel()
        Gets the component for the title.
        Returns:
        a JLabel.
      • getSubtitleLabel

        public javax.swing.JComponent getSubtitleLabel()
        Gets the component for the subtitle.
        Returns:
        a MultilineLabel by default