Class ColorLabel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class ColorLabel extends JComponent
Author:
heddle
See Also:
  • Constructor Details

    • ColorLabel

      public ColorLabel(IColorChangeListener colorChangeListener, Color intitialColor, String prompt)
      Create a clickable color label.
      Parameters:
      colorChangeListener - the listener for color changes.
      intitialColor - the intial color.
      prompt - the prompt string.
    • ColorLabel

      public ColorLabel(Color color, Font font, String prompt)
      Create an inert color label.
      Parameters:
      color - the color.
      prompt - the prompt string.
    • ColorLabel

      public ColorLabel(IColorChangeListener colorChangeListener, Color intitialColor, String prompt, int desiredWidth)
      Create a clickable color label.
      Parameters:
      colorChangeListener - the listener for color changes.
      intitialColor - the initial color.
      prompt - the prompt string.
      desiredWidth - if positive the desired total width.
    • ColorLabel

      public ColorLabel(IColorChangeListener colorChangeListener, Color intitialColor, Font font, String prompt)
      Create a clickable color label.
      Parameters:
      colorChangeListener - the listener for color changes.
      intitialColor - the initial color.
      prompt - the prompt string.
    • ColorLabel

      public ColorLabel(IColorChangeListener colorChangeListener, Color intitialColor, Font font, String prompt, int desiredWidth)
      Create a clickable color label.
      Parameters:
      colorChangeListener - the listener for color changes.
      intitialColor - the initial color.
      prompt - the prompt string.
      desiredWidth - if positive the desired total width.
  • Method Details

    • paintComponent

      public void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • setColorListener

      public void setColorListener(IColorChangeListener listener)
      Set the color change listener.
      Parameters:
      listener - the color change listener.
    • getColor

      public Color getColor()
      Return the current color.
      Returns:
      the current color.
    • setColor

      public void setColor(Color newColor)
      Set the new color.
      Parameters:
      newColor - the new color index.