Class ColorButton

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public final class ColorButton extends JButton
JButton that opens a Color Chooser when clicked and shows the previously set color as an icon. You can use the addPropertyChangeListener method to listen for a PropertyChangeEvent (for the property "color") whenever a new color is selected by the user.
See Also:
Serialized Form

Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Module: swing-util-api

To use this in your app, include the following dependency in your POM:

<dependency>
    <groupId>org.cytoscape</groupId>
    <artifactId>swing-util-api</artifactId>
</dependency>
  • Constructor Details

    • ColorButton

      public ColorButton(Color color)
      The basic constructor for a color button without palettes. The color argument is the initial color.
      Parameters:
      color -
    • ColorButton

      public ColorButton(CyServiceRegistrar serviceRegistrar, Palette palette, PaletteType type, Color color, boolean paletteOnly)
      The basic constructor for a color button with palettes. The color argument is the initial color, and the palette argument is the initial palette. Because palettes are dynamic, the caller must provide the CyServiceRegistrar service and pass that to this constructor.
      Parameters:
      serviceRegistrar - the CyServiceRegistrar -- used to get all of the currently available palettes
      palette - the initial palette
      paletteType - the types of palettes to use
      color - the initial color
      paletteOnly - if true, only allow palette selection, not color selection
  • Method Details

    • setColor

      public void setColor(Color color)
      Sets a new color and fires a PropertyChangeEvent for the property "color".
      Parameters:
      color -
    • setPalette

      public void setPalette(Palette palette)
      Sets a new color Palette and fires a PropertyChangeEvent for the property "palette".
      Parameters:
      palette -
    • getColor

      public Color getColor()
      Returns:
      The currently selected color.
    • getPalette

      public Palette getPalette()
      Returns:
      The currently selected palette (if any).