Class BannerPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class BannerPanel extends 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:
  • Field Details

    • _title

      protected String _title
      Title of the banner panel.
    • _subtitle

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

      protected ImageIcon _titleIcon
      Icon for the banner panel.
    • TITLE_PROPERTY

      public static final String TITLE_PROPERTY
      See Also:
    • SUBTITLE_PROPERTY

      public static final String SUBTITLE_PROPERTY
      See Also:
    • ICON_PROPERTY

      public static final String ICON_PROPERTY
      See Also:
    • ICON_COMPONENT_PROPERTY

      public static final String ICON_COMPONENT_PROPERTY
      See Also:
    • PROPERTY_TITLE_FONT

      public static final String PROPERTY_TITLE_FONT
      See Also:
    • PROPERTY_SUBTITLE_FONT

      public static final String PROPERTY_SUBTITLE_FONT
      See Also:
    • PROPERTY_TITLE_ICON_LOCATION

      public static final String PROPERTY_TITLE_ICON_LOCATION
      See Also:
    • _subTitleIndent

      protected int _subTitleIndent
    • _titleFont

      protected Font _titleFont
    • _titleColor

      protected Color _titleColor
    • _subTitleFont

      protected Font _subTitleFont
    • _subTitleColor

      protected Color _subTitleColor
    • _backgroundPaint

      protected Paint _backgroundPaint
    • _propertyListener

      protected PropertyChangeListener _propertyListener
    • _startColor

      protected Color _startColor
    • _endColor

      protected Color _endColor
    • _isVertical

      protected boolean _isVertical
    • _textPanel

      public JPanel _textPanel
  • Constructor Details

    • BannerPanel

      public BannerPanel()
      Creates an empty BannerPanel.
    • BannerPanel

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

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

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

      public BannerPanel(String title, String subtitle, 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 Details

    • lazyInitialize

      public void lazyInitialize()
    • createSubtitleLabel

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

      protected ImageIcon prepareTitleIcon(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 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(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(Color startColor, 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(Graphics g)
      Paints the background.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - the Graphics
    • getTitle

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

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

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

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

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

      public void setTitleIcon(ImageIcon titleIcon)
      Sets the title icon.
      Parameters:
      titleIcon - the new titleIcon.
    • getIconComponent

      public JComponent getIconComponent()
      Gets the icon component. If you use constructor BannerPanel(String,String,javax.swing.ImageIcon), the icon component will be a JLabel with the icon in the 3rd parameter. If you use the constructor BannerPanel(String,String,javax.swing.JComponent), it will return the component as in the 3rd parameter.
      Returns:
      the icon component
    • setIconComponent

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

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

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

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

      public void setTitleFont(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 Color getTitleColor()
      Gets the title color.
      Returns:
      the color of title.
    • setTitleColor

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

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

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

      public void setBackground(Color bg)
      Overrides:
      setBackground in class JComponent
    • setForeground

      public void setForeground(Color fg)
      Overrides:
      setForeground in class JComponent
    • getStartColor

      public Color getStartColor()
    • setStartColor

      public void setStartColor(Color startColor)
    • getEndColor

      public Color getEndColor()
    • setEndColor

      public void setEndColor(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 JComponent getTitleLabel()
      Gets the component for the title.
      Returns:
      a JLabel.
    • getSubtitleLabel

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