com.colorpicker.swing
Class ColorPicker

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.colorpicker.swing.ColorPicker
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class ColorPicker
extends javax.swing.JPanel

This is a panel that offers a robust set of controls to pick a color.

This was originally intended to replace the JColorChooser. To use this class to create a color choosing dialog, simply call:
ColorPicker.showDialog(frame, originalColor);

However this panel is also resizable, and it can exist in other contexts. For example, you might try the following panel:
ColorPicker picker = new ColorPicker(false, false);
picker.setPreferredSize(new Dimension(200,160));
picker.setMode(ColorPicker.HUE);

This will create a miniature color picker that still lets the user choose from every available color, but it does not include all the buttons and numeric controls on the right side of the panel. This might be ideal if you are working with limited space, or non-power-users who don't need the RGB values of a color. The main() method of this class demonstrates possible ways you can customize a ColorPicker component.

To listen to color changes to this panel, you can add a PropertyChangeListener listening for changes to the SELECTED_COLOR_PROPERTY. This will be triggered only when the RGB value of the selected color changes.

To listen to opacity changes to this panel, use a PropertyChangeListener listening for changes to the OPACITY_PROPERTY.

See Also:
Serialized Form

Nested Class Summary
(package private)  class ColorPicker.HexDocumentListener
           
(package private)  class ColorPicker.HexUpdateThread
          This thread will wait a second or two before committing the text in the hex TextField.
(package private)  class ColorPicker.Option
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  java.awt.event.ActionListener actionListener
           
private  int adjustingColorPanel
          Used to indicate when we're internally adjusting the selected color of the ColorPanel.
private  int adjustingHexField
          Used to indicate when we're internally adjusting the value of the hex field.
private  int adjustingOpacity
          Used to indicate when we're internally adjusting the value of the opacity.
private  int adjustingSlider
          Used to indicate when we're internally adjusting the value of the slider.
private  int adjustingSpinners
          Used to indicate when we're internally adjusting the value of the spinners.
private  ColorPicker.Option alpha
           
private  ColorPicker.Option blue
           
protected static int BLUE
          Used to indicate when we're in "blue mode".
private  ColorPicker.Option bri
           
protected static int BRI
          Used to indicate when we're in "brightness mode".
(package private)  javax.swing.event.ChangeListener changeListener
           
private  ColorPickerPanel colorPanel
           
private  javax.swing.JPanel expertControls
          The "expert" controls are the controls on the right side of this panel: the labels/spinners/radio buttons.
private  ColorPicker.Option green
           
protected static int GREEN
          Used to indicate when we're in "green mode".
static java.lang.String HEX_COLOR_PROPERTY
          PropertyChangeEvents will be triggered when the Hexadecimal value changes.
(package private)  ColorPicker.HexDocumentListener hexDocListener
           
private  javax.swing.JTextField hexField
           
private  javax.swing.JLabel hexLabel
           
private  ColorPicker.Option hue
           
protected static int HUE
          Used to indicate when we're in "hue mode".
private  float lastOpacity
           
static java.lang.String MODE_CONTROLS_VISIBLE_PROPERTY
          PropertyChangeEvents will be triggered for this property when setModeControlsVisible() is called.
static java.lang.String MODE_PROPERTY
          PropertyChangeEvents will be triggered when the mode changes.
static java.lang.String OPACITY_PROPERTY
          PropertyChangeEvents will be triggered when the opacity value is adjusted.
private  javax.swing.JLabel opacityLabel
           
private  javax.swing.JSlider opacitySlider
           
private  ColorSwatch preview
           
private  ColorPicker.Option red
           
protected static int RED
          Used to indicate when we're in "red mode".
private  ColorPicker.Option sat
           
protected static int SAT
          Used to indicate when we're in "saturation mode".
static java.lang.String SELECTED_COLOR_PROPERTY
          PropertyChangeEvents will be triggered for this property when the selected color changes.
private static long serialVersionUID
           
private  javax.swing.JSlider slider
          The vertical slider
protected static java.util.ResourceBundle strings
          The localized strings used in this (and related) panel(s).
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ColorPicker()
          Create a new ColorPicker with all controls visible except opacity.
ColorPicker(boolean showExpertControls, boolean includeOpacity)
          Create a new ColorPicker.
 
Method Summary
 java.awt.Color getColor()
           
 ColorPickerPanel getColorPanel()
           
 javax.swing.JPanel getExpertControls()
          This returns the panel with several rows of spinner controls.
 float[] getHSB()
           
 int getMode()
           
 float getOpacity()
          Returns the currently selected opacity (a float between 0 and 1).
 int[] getRGB()
           
private  ColorPicker.Option getSelectedOption()
           
static void main(java.lang.String[] args)
          This demonstrates how to customize a small ColorPicker component.
 void setColor(java.awt.Color c)
          Sets the current color of this ColorPicker.
 void setExpertControlsVisible(boolean b)
          The labels/spinners/buttons on the right side of a ColorPicker are optional.
 void setHexControlsVisible(boolean b)
          This controls whether the hex field (and label) are visible or not.
 void setHSB(float h, float s, float b)
          Sets the current color of this ColorPicker
 void setHSBControlsVisible(boolean b)
          This shows or hides the HSB spinner controls.
 void setMode(int mode)
          Sets the mode of this ColorPicker.
 void setModeControlsVisible(boolean b)
          This controls whether the radio buttons that adjust the mode are visible.
 void setOpacity(float v)
          Sets the currently selected opacity.
 void setOpacityVisible(boolean b)
          This shows or hides the alpha controls.
 void setPreviewSwatchVisible(boolean b)
          This controls whether the preview swatch visible or not.
 void setRGB(int r, int g, int b)
          Sets the current color of this ColorPicker
 void setRGBControlsVisible(boolean b)
          This shows or hides the RGB spinner controls.
static java.awt.Color showDialog(java.awt.Window owner, java.awt.Color originalColor)
          This creates a modal dialog prompting the user to select a color.
static java.awt.Color showDialog(java.awt.Window owner, java.awt.Color originalColor, boolean includeOpacity)
          This creates a modal dialog prompting the user to select a color.
static java.awt.Color showDialog(java.awt.Window owner, java.lang.String title, java.awt.Color originalColor, boolean includeOpacity)
          This creates a modal dialog prompting the user to select a color.
private  void updateHexField()
           
private  void updateSlider()
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

strings

protected static java.util.ResourceBundle strings
The localized strings used in this (and related) panel(s).


SELECTED_COLOR_PROPERTY

public static final java.lang.String SELECTED_COLOR_PROPERTY
PropertyChangeEvents will be triggered for this property when the selected color changes.

(Events are only created when then RGB values of the color change. This means, for example, that the change from HSB(0,0,0) to HSB(.4,0,0) will not generate events, because when the brightness stays zero the RGB color remains (0,0,0). So although the hue moved around, the color is still black, so no events are created.)

See Also:
Constant Field Values

HEX_COLOR_PROPERTY

public static final java.lang.String HEX_COLOR_PROPERTY
PropertyChangeEvents will be triggered when the Hexadecimal value changes. (Fix by frederic.roudaut@free.fr because of some problems with SELECTED_COLOR_PROPERTY)

See Also:
Constant Field Values

MODE_CONTROLS_VISIBLE_PROPERTY

public static final java.lang.String MODE_CONTROLS_VISIBLE_PROPERTY
PropertyChangeEvents will be triggered for this property when setModeControlsVisible() is called.

See Also:
Constant Field Values

OPACITY_PROPERTY

public static final java.lang.String OPACITY_PROPERTY
PropertyChangeEvents will be triggered when the opacity value is adjusted.

See Also:
Constant Field Values

MODE_PROPERTY

public static final java.lang.String MODE_PROPERTY
PropertyChangeEvents will be triggered when the mode changes. (That is, when the wheel switches from HUE, SAT, BRI, RED, GREEN, or BLUE modes.)

See Also:
Constant Field Values

HUE

protected static final int HUE
Used to indicate when we're in "hue mode".

See Also:
Constant Field Values

BRI

protected static final int BRI
Used to indicate when we're in "brightness mode".

See Also:
Constant Field Values

SAT

protected static final int SAT
Used to indicate when we're in "saturation mode".

See Also:
Constant Field Values

RED

protected static final int RED
Used to indicate when we're in "red mode".

See Also:
Constant Field Values

GREEN

protected static final int GREEN
Used to indicate when we're in "green mode".

See Also:
Constant Field Values

BLUE

protected static final int BLUE
Used to indicate when we're in "blue mode".

See Also:
Constant Field Values

slider

private javax.swing.JSlider slider
The vertical slider


changeListener

javax.swing.event.ChangeListener changeListener

actionListener

java.awt.event.ActionListener actionListener

hexDocListener

ColorPicker.HexDocumentListener hexDocListener

alpha

private ColorPicker.Option alpha

hue

private ColorPicker.Option hue

sat

private ColorPicker.Option sat

bri

private ColorPicker.Option bri

red

private ColorPicker.Option red

green

private ColorPicker.Option green

blue

private ColorPicker.Option blue

preview

private ColorSwatch preview

hexLabel

private javax.swing.JLabel hexLabel

hexField

private javax.swing.JTextField hexField

adjustingSpinners

private int adjustingSpinners
Used to indicate when we're internally adjusting the value of the spinners. If this equals zero, then incoming events are triggered by the user and must be processed. If this is not equal to zero, then incoming events are triggered by another method that's already responding to the user's actions.


adjustingSlider

private int adjustingSlider
Used to indicate when we're internally adjusting the value of the slider. If this equals zero, then incoming events are triggered by the user and must be processed. If this is not equal to zero, then incoming events are triggered by another method that's already responding to the user's actions.


adjustingColorPanel

private int adjustingColorPanel
Used to indicate when we're internally adjusting the selected color of the ColorPanel. If this equals zero, then incoming events are triggered by the user and must be processed. If this is not equal to zero, then incoming events are triggered by another method that's already responding to the user's actions.


adjustingHexField

private int adjustingHexField
Used to indicate when we're internally adjusting the value of the hex field. If this equals zero, then incoming events are triggered by the user and must be processed. If this is not equal to zero, then incoming events are triggered by another method that's already responding to the user's actions.


adjustingOpacity

private int adjustingOpacity
Used to indicate when we're internally adjusting the value of the opacity. If this equals zero, then incoming events are triggered by the user and must be processed. If this is not equal to zero, then incoming events are triggered by another method that's already responding to the user's actions.


expertControls

private javax.swing.JPanel expertControls
The "expert" controls are the controls on the right side of this panel: the labels/spinners/radio buttons.


colorPanel

private ColorPickerPanel colorPanel

opacitySlider

private javax.swing.JSlider opacitySlider

opacityLabel

private javax.swing.JLabel opacityLabel

lastOpacity

private float lastOpacity
Constructor Detail

ColorPicker

public ColorPicker()
Create a new ColorPicker with all controls visible except opacity.


ColorPicker

public ColorPicker(boolean showExpertControls,
                   boolean includeOpacity)
Create a new ColorPicker.

Parameters:
showExpertControls - the labels/spinners/buttons on the right side of a ColorPicker are optional. This boolean will control whether they are shown or not.

It may be that your users will never need or want numeric control when they choose their colors, so hiding this may simplify your interface.

includeOpacity - whether the opacity controls will be shown
Method Detail

main

public static void main(java.lang.String[] args)
This demonstrates how to customize a small ColorPicker component.


showDialog

public static java.awt.Color showDialog(java.awt.Window owner,
                                        java.awt.Color originalColor)
This creates a modal dialog prompting the user to select a color.

This uses a generic dialog title: "Choose a Color", and does not include opacity.

Parameters:
owner - the dialog this new dialog belongs to. This must be a Frame or a Dialog. Java 1.6 supports Windows here, but this package is designed/compiled to work in Java 1.4, so an IllegalArgumentException will be thrown if this component is a Window.
originalColor - the color the ColorPicker initially points to.
Returns:
the Color the user chooses, or null if the user cancels the dialog.

showDialog

public static java.awt.Color showDialog(java.awt.Window owner,
                                        java.awt.Color originalColor,
                                        boolean includeOpacity)
This creates a modal dialog prompting the user to select a color.

This uses a generic dialog title: "Choose a Color".

Parameters:
owner - the dialog this new dialog belongs to. This must be a Frame or a Dialog. Java 1.6 supports Windows here, but this package is designed/compiled to work in Java 1.4, so an IllegalArgumentException will be thrown if this component is a Window.
originalColor - the color the ColorPicker initially points to.
includeOpacity - whether to add a control for the opacity of the color.
Returns:
the Color the user chooses, or null if the user cancels the dialog.

showDialog

public static java.awt.Color showDialog(java.awt.Window owner,
                                        java.lang.String title,
                                        java.awt.Color originalColor,
                                        boolean includeOpacity)
This creates a modal dialog prompting the user to select a color.

Parameters:
owner - the dialog this new dialog belongs to. This must be a Frame or a Dialog. Java 1.6 supports Windows here, but this package is designed/compiled to work in Java 1.4, so an IllegalArgumentException will be thrown if this component is a Window.
title - the title for the dialog.
originalColor - the color the ColorPicker initially points to.
includeOpacity - whether to add a control for the opacity of the color.
Returns:
the Color the user chooses, or null if the user cancels the dialog.

getSelectedOption

private ColorPicker.Option getSelectedOption()
Returns:
the currently selected Option

setHexControlsVisible

public void setHexControlsVisible(boolean b)
This controls whether the hex field (and label) are visible or not.

Note this lives inside the "expert controls", so if setExpertControlsVisible(false) has been called, then calling this method makes no difference: the hex controls will be hidden.


setPreviewSwatchVisible

public void setPreviewSwatchVisible(boolean b)
This controls whether the preview swatch visible or not.

Note this lives inside the "expert controls", so if setExpertControlsVisible(false) has been called, then calling this method makes no difference: the swatch will be hidden.


setExpertControlsVisible

public void setExpertControlsVisible(boolean b)
The labels/spinners/buttons on the right side of a ColorPicker are optional. This method will control whether they are shown or not.

It may be that your users will never need or want numeric control when they choose their colors, so hiding this may simplify your interface.

Parameters:
b - whether to show or hide the expert controls.

getHSB

public float[] getHSB()
Returns:
the current HSB coordinates of this ColorPicker. Each value is between [0,1].

getRGB

public int[] getRGB()
Returns:
the current RGB coordinates of this ColorPicker. Each value is between [0,255].

getOpacity

public float getOpacity()
Returns the currently selected opacity (a float between 0 and 1).

Returns:
the currently selected opacity (a float between 0 and 1).

setOpacity

public void setOpacity(float v)
Sets the currently selected opacity.

Parameters:
v - a float between 0 and 1.

setMode

public void setMode(int mode)
Sets the mode of this ColorPicker. This is especially useful if this picker is in non-expert mode, so the radio buttons are not visible for the user to directly select.

Parameters:
mode - must be HUE, SAT, BRI, RED, GREEN or BLUE.

setModeControlsVisible

public void setModeControlsVisible(boolean b)
This controls whether the radio buttons that adjust the mode are visible.

(These buttons appear next to the spinners in the expert controls.)

Note these live inside the "expert controls", so if setExpertControlsVisible(false) has been called, then these will never be visible.

Parameters:
b -

getMode

public int getMode()
Returns:
the current mode of this ColorPicker.
This will return HUE, SAT, BRI, RED, GREEN, or BLUE.

The default mode is BRI, because that provides the most aesthetic/recognizable color wheel.


setColor

public void setColor(java.awt.Color c)
Sets the current color of this ColorPicker. This method simply calls setRGB() and setOpacity().

Parameters:
c - the new color to use.

setRGB

public void setRGB(int r,
                   int g,
                   int b)
Sets the current color of this ColorPicker

Parameters:
r - the red value. Must be between [0,255].
g - the green value. Must be between [0,255].
b - the blue value. Must be between [0,255].

getColor

public java.awt.Color getColor()
Returns:
the current Color this ColorPicker has selected.

This is equivalent to:
int[] i = getRGB();
return new Color(i[0], i[1], i[2], opacitySlider.getValue());


updateSlider

private void updateSlider()

getExpertControls

public javax.swing.JPanel getExpertControls()
This returns the panel with several rows of spinner controls.

Note you can also call methods such as setRGBControlsVisible() to adjust which controls are showing.

(This returns the panel this ColorPicker uses, so if you put it in another container, it will be removed from this ColorPicker.)

Returns:
the panel with several rows of spinner controls.

setRGBControlsVisible

public void setRGBControlsVisible(boolean b)
This shows or hides the RGB spinner controls.

Note these live inside the "expert controls", so if setExpertControlsVisible(false) has been called, then calling this method makes no difference: the RGB controls will be hidden.

Parameters:
b - whether the controls should be visible or not.

setHSBControlsVisible

public void setHSBControlsVisible(boolean b)
This shows or hides the HSB spinner controls.

Note these live inside the "expert controls", so if setExpertControlsVisible(false) has been called, then calling this method makes no difference: the HSB controls will be hidden.

Parameters:
b - whether the controls should be visible or not.

setOpacityVisible

public void setOpacityVisible(boolean b)
This shows or hides the alpha controls.

Note the alpha spinner live inside the "expert controls", so if setExpertControlsVisible(false) has been called, then this method does not affect that spinner. However, the opacity slider is not affected by the visibility of the export controls.

Parameters:
b -

getColorPanel

public ColorPickerPanel getColorPanel()
Returns:
the ColorPickerPanel this ColorPicker displays.

setHSB

public void setHSB(float h,
                   float s,
                   float b)
Sets the current color of this ColorPicker

Parameters:
h - the hue value.
s - the saturation value. Must be between [0,1].
b - the blue value. Must be between [0,1].

updateHexField

private void updateHexField()