Class GradientLabel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
Direct Known Subclasses:
SimpleButton

public class GradientLabel extends ResizableTextLabel
A label that paints a gradient as a background. User can specify gradient colors (one of them is the default label background) and direction (the default is from the upper left to the upper right corner) relative to the label's proportions.
Version:
$id$
Author:
Miha Kadunc
See Also:
  • Constructor Details

    • GradientLabel

      public GradientLabel()
      Constructs an empty GradientLabel
    • GradientLabel

      public GradientLabel(Icon image)
      Constructs a GradientLabel with the specified icon.
      Parameters:
      image -
    • GradientLabel

      public GradientLabel(Icon image, int horizontalAlignment)
      Constructor for GradientLabel.
      Parameters:
      image -
      horizontalAlignment -
    • GradientLabel

      public GradientLabel(String text)
      Constructs a GradientLabel with the specified text.
      Parameters:
      text -
    • GradientLabel

      public GradientLabel(String text, Icon icon, int horizontalAlignment)
      Constructor for GradientLabel.
      Parameters:
      text -
      icon -
      horizontalAlignment -
    • GradientLabel

      public GradientLabel(String text, int horizontalAlignment)
      Constructor for GradientLabel.
      Parameters:
      text -
      horizontalAlignment -
  • Method Details

    • getBackgroundStart

      public Color getBackgroundStart()
      Returns the backgroundStart, this is the color that is used for the start of label's gradient. The end color is that of the label's background.
      Returns:
      Color
    • isGradientEnabled

      public boolean isGradientEnabled()
      Returns whether the gradient background is enabled.
      Returns:
      boolean
    • paintComponent

      protected void paintComponent(Graphics g)
      Description copied from class: ResizableTextLabel
      This method hes been overriden to implement the feature of enhanced anti-aliasing paint of the label.
      Overrides:
      paintComponent in class ResizableTextLabel
      See Also:
    • setBackground

      public void setBackground(Color c)
      Sets the background color. This color is used for the gradient's end point.
      Overrides:
      setBackground in class JComponent
      Parameters:
      c - The color to be set
      See Also:
    • setBackgroundStart

      public void setBackgroundStart(Color newBackgroundStart)
      Sets the backgroundStart color.
      Parameters:
      newBackgroundStart - The backgroundStart to set
      See Also:
    • setGradientEnabled

      public void setGradientEnabled(boolean gradientEnabled)
      Sets the gradientEnabled property.
      Parameters:
      gradientEnabled - The gradientEnabled to set
      See Also:
    • setGradientPoints

      public void setGradientPoints(double startX, double startY, double endX, double endY)
      Sets the start and end point of the label's gradient, relative to the label's size. Value 0 is the left/top edge of the label. 1 is the right/bottom edge of the label.
      Parameters:
      startX - the x coordinate of the start of the gradient
      startY - the y coordinate of the start of the gradient
      endX - the x coordinate of the end of the gradient
      endY - the y coordinate of the end of the gradient