Class ColorSwatch

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ColorSwatch extends JPanel
Displays a color swatch.
Since:
August 16, 2010
Author:
noblemaster
See Also:
Serialized Form
  • Constructor Details

    • ColorSwatch

      public ColorSwatch()
      The constructor.
    • ColorSwatch

      public ColorSwatch(Color[][] colors)
      The constructor.
      Parameters:
      colors - The colors to select from.
  • Method Details

    • getColors

      public Color[][] getColors()
      Returns the colors.
      Returns:
      The colors.
    • setColors

      public void setColors(Color[][] colors)
      Sets the colors.
      Parameters:
      colors - The colors.
    • getPreferredSize

      public Dimension getPreferredSize()
      Returns the preferred size.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      The preferred size.
    • getMargin

      public int getMargin()
      Returns the margin/insets from where the colors are painted. Override this method to paint the colors further inside.
      Returns:
      The margin.
    • paintComponent

      protected void paintComponent(Graphics g)
      Draws this component.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - Where to draw to.
    • addColorListener

      public void addColorListener(ColorSwatch.ColorListener listener)
      Adds a listener.
      Parameters:
      listener - The listener.
    • removeColorListener

      public void removeColorListener(ColorSwatch.ColorListener listener)
      Removes a listener.
      Parameters:
      listener - The listener.