Class SimpleColorChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class SimpleColorChooser extends JPanel
The SimpleColorChooser class is a panel that displays a simple grid of colors from which to choose, with a button to display a full JColorChooser dialog. When the user selects a color, either from the simple grid or from the full Swing color chooser, a property change event is fired whose property is given by COLOR_PROPERTY.
Since:
3.1.7
Author:
Peter Hollemans
See Also:
  • Field Details

    • COLOR_PROPERTY

      public static String COLOR_PROPERTY
      The color property.
    • chooserButton

      protected JButton chooserButton
      The button used for activating the JColorChooser.
  • Constructor Details

    • SimpleColorChooser

      public SimpleColorChooser(int rows, int cols, Color color)
      Creates a new simple color chooser with the specified number of swatch rows and columns.
      Parameters:
      rows - the number of swatch rows.
      cols - the number of swatch columns.
      color - the initial color for the main color chooser.
  • Method Details

    • getColor

      public Color getColor()
      Gets the color selected by this color chooser.
    • setColor

      public void setColor(Color newColor)
      Sets the color selected by this color chooser. The color may be null, in which case this method has no effect.
    • main

      public static void main(String[] argv)
      Tests this class.
      Parameters:
      argv - the array of command line parameters.