Oracle JEWT 4.2.10

oracle.bali.ewt.chooser.color
Class ColorChoice

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.AbstractButton
                          |
                          +--javax.swing.JButton
                                |
                                +--oracle.bali.ewt.chooser.color.ColorChoice
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants

public class ColorChoice
extends javax.swing.JButton

This class implements a simple color choice. The component looks like a button, with Icons or String label, until the color grid is activated by pushing the button or using the alt-down sequence.

The ColorChoice will display a default Image in the button. This image contains an area that will automatically be changed to match the currently selected color.

Clients can call setImage(Image, Color) to set their own Image on the ColorChoice. Every pixel in the Image that matches the Color will be changed to the currently selected color every time the selected color changes.

Alternatively, clients can use the JButton methods setIcon(), setDisabledIcon(), etc. If clients change the icon or disabledIcon the ColorChoice will not be able to automatically update the image to display the currently selected color.

The ColorChoice also the selection of a transparent color. If isTransparentAllowed() returns true the user will be able to select a toggle button when the color grid is dropped down that corresponds to no selected color. getSelectedColor() will return null in this case.

The ColorChoice also allows users to edit the color palette. If isEditAllowed() returns true an edit button is displayed below the pop down grid that displays a ColorPalettePane. Users can then add and delete colors or replace colors in the grid. The ColorChoice will fire a PROPERTY_COLOR_PALETTE event when the user changes the palette. Alternatively, clients can add a TwoDModelListener to the TwoDModel of colors to see if it changes.

ColorChoice now supports an automatic mode. If users choose this button than the application should automatically pick the correct color. The ColorChoice will display a different icon in the button to indicate that the automatic mode is selected. Clients can display the automatic button by calling setAutomaticAllowed(). Clients can listen to changes in the state of automatic by listening for PROPERTY_AUTOMATIC_SELECTED events. When automatic is selected the selected color is set to null.

ColorChoice now supports a default color. If isDefaultAllowed() is true a button is displayed above the color palette that lets the user choose the defaultColor. The selectedColor will then become the defaultColor and a PROPERTY_DEFAULT_SELECTED event is sent.

The Oracle User Interface team has defined a set of common color palettes that can be used with the ColorChoice. Please see ColorGrid.getColorPalette(int) for a list of these common palettes.

Event

The ColorChoice fires a PROPERTY_SELECTED_COLOR PropertyChangeEvent when the selected color changes.

The ColorChoice fires a PROPERTY_AUTOMATIC_SELECTED PropertyChangeEvent when the user changes automaticSelected property..

The ColorChoice fires a PROPERTY_DEFAULT_SELECTED PropertyChangeEvent when the user changes defaultSelected property..

The ColorChoice fires a PROPERTY_COLOR_PALETTE PropertyChangeEvent if the user edits the color palette displayed in the ColorChoice.

See Also:
TwoDModel, oracle.bali.ewt.color.ColorGrid, Serialized Form

Inner classes inherited from class javax.swing.JButton
javax.swing.JButton.AccessibleJButton
 
Inner classes inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.lang.String PROPERTY_AUTOMATIC_SELECTED
          The PropertyName to listen for when the user changes the value of the automatic mode in the drop down list of the ColorChoice.
static java.lang.String PROPERTY_COLOR_PALETTE
          The PropertyName to listen for when the user changes the custom Color Palette displayed in the drop down list of the ColorChoice.
static java.lang.String PROPERTY_DEFAULT_SELECTED
          The PropertyName to listen for when the user changes the chooses the default color (or chooses a color in the palette).
static java.lang.String PROPERTY_SELECTED_COLOR
          The PropertyName to listen for when the user changes the selected color.
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ColorChoice()
          Create a color choice with no label, the default icon, the default palette and no selected color.
ColorChoice(javax.swing.Icon icon)
          Create a color choice with the no label, the given icon, the default palette and no selected color.
ColorChoice(javax.swing.Icon icon, TwoDModel colorPalette, java.awt.Color selectColor)
          Create a ColorChoice object that look like a button with an icon label.
ColorChoice(java.lang.String label)
          Create a color choice with the given label, the default icon, the default palette and no selected color.
ColorChoice(java.lang.String label, TwoDModel colorPalette, java.awt.Color selectColor)
          Create a ColorChoice object that lookl like a button with a text label.
 
Method Summary
 void addNotify()
          Overridden to update the strings used in the ColorChoice.
protected  void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Subclass so inner classes can access.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Override to return a new AccessibleContext.
 java.awt.Color getClosestColor(java.awt.Color color)
          Return a Color in the ColorChoice's main palette that is closest to the given color.
 java.awt.Color getClosestColor(java.awt.Color color, boolean useCustomPalette)
          Return a Color in the either the ColorChoice's main palette or custom palette that is closest to the given color.
 TwoDModel getColorPalette()
          Returns the TwoDModel of colors that the ColorChoice shows.
 ColorPalettePane getColorPalettePane()
          Get the ColorPalettePane object used to edit the color palettes.
 java.awt.Color getColorToChange()
          Get the Color to change in the Image from getImage().
 TwoDModel getCustomColorPalette()
          Get the custom color palette that the ColorChoice uses.
 java.awt.Color getDefaultColor()
          Get the default color used by the ColorChoice.
 java.awt.Image getImage()
          Get the Image to use to create the icons in the button.
 java.awt.Color getSelectedColor()
          Returns the color that is currently selected, or null if there is no selected color.
 boolean isAutomaticAllowed()
          Returns true if a toggle button is displayed when the color grid is dropped down that allows users to choose the automatic option.
 boolean isAutomaticSelected()
          Return true if the user has chosen the automatic mode.
static boolean isColorInPalette(TwoDModel palette, java.awt.Color c)
          Return true if the given color is in the given palette.
 boolean isCustomColorSelected()
          Returns true if the currently selected color is in the custom palette.
 boolean isDefaultAllowed()
          Returns true if a button is displayed when the color grid is dropped down that allows users to choose the default color.
 boolean isDefaultSelected()
          Return true if the user has chosen the default color.
 boolean isEditAllowed()
          Returns true if a button is displayed when the color grid is dropped down that allows users to change the color palette shown in the ColorChoice.
 boolean isTransparentAllowed()
          Returns true if a toggle button is displayed when the color grid is dropped down that allows users to choose a transparent color (no color).
 void removeNotify()
          Overridden to take down the dropdown grid when the ColorChoice is taken out of the component hierarchy.
 void setAutomaticAllowed(boolean automaticAllowed)
          Set if a toggle button is displayed when the color grid is dropped down that allows users to the automatic option.
 void setAutomaticSelected(boolean selected)
          Set if the user has chosen the automatic mode.
 void setColorPalette(TwoDModel colorPalette)
          Change the TwoDModel of colors that the ColorChoice uses.
 void setCustomColorPalette(TwoDModel colorPalette)
          Set the custom color palette that the ColorChoice uses.
 void setDefaultAllowed(boolean defaultAllowed)
          Set if a button is displayed when the color grid is dropped down that allows users to pick the default color.
 void setDefaultColor(java.awt.Color defaultColor)
          Set the default color used by the ColorChoice.
 void setDefaultSelected(boolean selected)
          Set if the user has chosen the default color.
 void setDisabledIcon(javax.swing.Icon icon)
          Override to clear the Image.
 void setEditAllowed(boolean isEditAllowed)
          Set if a button is displayed when the color grid is dropped down that allows users to change the color palette shown in the ColorChoice.
 void setIcon(javax.swing.Icon icon)
          Override to clear the Image.
 void setImage(java.awt.Image image, java.awt.Color colorToChange)
          Set the Image used in the ColorChoice.
 void setLocale(java.util.Locale l)
          Override to change the strings used in the ColorChoice.
 void setSelectedColor(java.awt.Color c)
          Sets the selected color in the default grid.
 void setSelectedColor(java.awt.Color c, boolean colorInCustomPalette)
          Sets the selected color in the either of the models.
 void setTransparentAllowed(boolean transparentAllowed)
          Set if a toggle button is displayed when the color grid is dropped down that allows users to choose a transparent color (no color).
 void updateUI()
          Override to update ui of buttons
 
Methods inherited from class javax.swing.JButton
configurePropertiesFromAction, getUIClassID, isDefaultButton, isDefaultCapable, paramString, setDefaultCapable
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getDisabledIcon, getDisabledSelectedIcon, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getLabel, getMargin, getMnemonic, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isFocusTraversable, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledSelectedIcon, setEnabled, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setLabel, setMargin, setMnemonic, setMnemonic, setModel, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_SELECTED_COLOR

public static final java.lang.String PROPERTY_SELECTED_COLOR
The PropertyName to listen for when the user changes the selected color.

PROPERTY_COLOR_PALETTE

public static final java.lang.String PROPERTY_COLOR_PALETTE
The PropertyName to listen for when the user changes the custom Color Palette displayed in the drop down list of the ColorChoice.

PROPERTY_AUTOMATIC_SELECTED

public static final java.lang.String PROPERTY_AUTOMATIC_SELECTED
The PropertyName to listen for when the user changes the value of the automatic mode in the drop down list of the ColorChoice.

PROPERTY_DEFAULT_SELECTED

public static final java.lang.String PROPERTY_DEFAULT_SELECTED
The PropertyName to listen for when the user changes the chooses the default color (or chooses a color in the palette).
Constructor Detail

ColorChoice

public ColorChoice()
Create a color choice with no label, the default icon, the default palette and no selected color.

ColorChoice

public ColorChoice(java.lang.String label)
Create a color choice with the given label, the default icon, the default palette and no selected color.

ColorChoice

public ColorChoice(javax.swing.Icon icon)
Create a color choice with the no label, the given icon, the default palette and no selected color.

ColorChoice

public ColorChoice(java.lang.String label,
                   TwoDModel colorPalette,
                   java.awt.Color selectColor)
Create a ColorChoice object that lookl like a button with a text label.
Parameters:
label - a textual label to use for the button.
colorPalette - a TwoDModel that contains Color objects.
selectColor - a color from the colorPalette parameter to initially select.

ColorChoice

public ColorChoice(javax.swing.Icon icon,
                   TwoDModel colorPalette,
                   java.awt.Color selectColor)
Create a ColorChoice object that look like a button with an icon label.
Parameters:
icon - an Icon to use for the button.
colorPalette - a TwoDModel that contains Color objects.
selectColor - a color from the colorPalette parameter to initially select.
Method Detail

setIcon

public void setIcon(javax.swing.Icon icon)
Override to clear the Image. If clients call this method the ColorChoice will not be able to automatically change the image when the selected color changes.
Overrides:
setIcon in class javax.swing.AbstractButton
See Also:
setImage(java.awt.Image, java.awt.Color)

setDisabledIcon

public void setDisabledIcon(javax.swing.Icon icon)
Override to clear the Image. If clients call this method the ColorChoice will not be able to automatically change the image when the selected color changes
Overrides:
setDisabledIcon in class javax.swing.AbstractButton
See Also:
setImage(java.awt.Image, java.awt.Color)

setImage

public void setImage(java.awt.Image image,
                     java.awt.Color colorToChange)
Set the Image used in the ColorChoice. When the currently selected color has changed the ColorChoice will update the icon and disabledIcon so that every pixel in the image that matches colorToChange is changed to the currently selected color.
Parameters:
image - The base image to use as the icons for the ColorChoice
colorToChange - Every pixel that makes colorToChange in image will be transformed to the currently selected color

getImage

public java.awt.Image getImage()
Get the Image to use to create the icons in the button.
See Also:
setImage(java.awt.Image, java.awt.Color)

getColorToChange

public java.awt.Color getColorToChange()
Get the Color to change in the Image from getImage().
See Also:
getImage(), setImage(java.awt.Image, java.awt.Color)

setColorPalette

public void setColorPalette(TwoDModel colorPalette)
Change the TwoDModel of colors that the ColorChoice uses. If colorPalette is null the default color palette is used.

getColorPalette

public TwoDModel getColorPalette()
Returns the TwoDModel of colors that the ColorChoice shows.

setCustomColorPalette

public void setCustomColorPalette(TwoDModel colorPalette)
Set the custom color palette that the ColorChoice uses. The custom palette is displayed below the main color palette.

See Also:
getCustomColorPalette(), setColorPalette(oracle.bali.ewt.model.TwoDModel)

getCustomColorPalette

public TwoDModel getCustomColorPalette()
Get the custom color palette that the ColorChoice uses. The custom palette is displayed below the main color palette.

See Also:
setCustomColorPalette(oracle.bali.ewt.model.TwoDModel), setColorPalette(oracle.bali.ewt.model.TwoDModel)

isTransparentAllowed

public boolean isTransparentAllowed()
Returns true if a toggle button is displayed when the color grid is dropped down that allows users to choose a transparent color (no color). The default is false.
See Also:
setTransparentAllowed(boolean)

setTransparentAllowed

public void setTransparentAllowed(boolean transparentAllowed)
Set if a toggle button is displayed when the color grid is dropped down that allows users to choose a transparent color (no color). The default is false.
See Also:
isTransparentAllowed()

isEditAllowed

public boolean isEditAllowed()
Returns true if a button is displayed when the color grid is dropped down that allows users to change the color palette shown in the ColorChoice. A ColorPalettePane is displayed to allow the user to change the palette.

The default is false.

If the colorPalette is changed the ColorChoice will fire a PROPERTY_COLOR_PALETTE PropertyChangeEvent.

See Also:
setEditAllowed(boolean)

setEditAllowed

public void setEditAllowed(boolean isEditAllowed)
Set if a button is displayed when the color grid is dropped down that allows users to change the color palette shown in the ColorChoice. A ColorPalettePane is displayed to allow the user to change the palette.

The default is false.

If the colorPalette is changed the ColorChoice will fire a PROPERTY_COLOR_PALETTE PropertyChangeEvent.

See Also:
isEditAllowed()

isAutomaticAllowed

public boolean isAutomaticAllowed()
Returns true if a toggle button is displayed when the color grid is dropped down that allows users to choose the automatic option. The default is false.
See Also:
setAutomaticAllowed(boolean)

setAutomaticAllowed

public void setAutomaticAllowed(boolean automaticAllowed)
Set if a toggle button is displayed when the color grid is dropped down that allows users to the automatic option. The default is false.
See Also:
isAutomaticAllowed()

isAutomaticSelected

public boolean isAutomaticSelected()
Return true if the user has chosen the automatic mode.

setAutomaticSelected

public void setAutomaticSelected(boolean selected)
Set if the user has chosen the automatic mode.
See Also:
isAutomaticSelected(), isAutomaticAllowed()

isDefaultAllowed

public boolean isDefaultAllowed()
Returns true if a button is displayed when the color grid is dropped down that allows users to choose the default color. The default color is specified by setDefaultColor(). The default is false.
See Also:
setDefaultAllowed(boolean), setDefaultColor(java.awt.Color)

setDefaultAllowed

public void setDefaultAllowed(boolean defaultAllowed)
Set if a button is displayed when the color grid is dropped down that allows users to pick the default color. The default color is specified using setDefaultColor(). The default is false.
See Also:
isDefaultAllowed()

setDefaultColor

public void setDefaultColor(java.awt.Color defaultColor)
Set the default color used by the ColorChoice. If isDefaultAllowed() is true than a button will be presented to the user to allow them to pick this default color.
See Also:
isDefaultAllowed(), getDefaultColor()

getDefaultColor

public java.awt.Color getDefaultColor()
Get the default color used by the ColorChoice. If isDefaultAllowed() is true than a button will be presented to the user to allow them to pick this default color. If the default color is not specified than the first color in the color palette is used.
See Also:
isDefaultAllowed(), setDefaultColor(java.awt.Color)

isDefaultSelected

public boolean isDefaultSelected()
Return true if the user has chosen the default color.
See Also:
setDefaultSelected(boolean), isDefaultAllowed()

setDefaultSelected

public void setDefaultSelected(boolean selected)
Set if the user has chosen the default color. If true getSelectedColor() will be change to getDefaultColor() and a PropertyChangeEvent will be fired indicating that the default is selected as well as the selected color changed.
See Also:
isDefaultSelected(), isDefaultAllowed()

setSelectedColor

public void setSelectedColor(java.awt.Color c)
Sets the selected color in the default grid.

This must be a color from the model of getColorPalette().

Throws:
java.lang.IllegalArgumentException - if the color is not found in the color palette.

getSelectedColor

public java.awt.Color getSelectedColor()
Returns the color that is currently selected, or null if there is no selected color. This color can be in either the main palette or the custom palette. Clients can call isCustomColorSelected() to differentiate.

isCustomColorSelected

public boolean isCustomColorSelected()
Returns true if the currently selected color is in the custom palette. Returns false if the currently selected color is selected in the main palette.

setSelectedColor

public void setSelectedColor(java.awt.Color c,
                             boolean colorInCustomPalette)
Sets the selected color in the either of the models.

If colorInCustomPalette is false the the color must be in the getColorPalette() model. Otherwise the color must be in the getCustomColorPalette() model.

Throws:
java.lang.IllegalArgumentException - if the color is not found in either of the color data sources.

getClosestColor

public java.awt.Color getClosestColor(java.awt.Color color)
Return a Color in the ColorChoice's main palette that is closest to the given color.

getClosestColor

public java.awt.Color getClosestColor(java.awt.Color color,
                                      boolean useCustomPalette)
Return a Color in the either the ColorChoice's main palette or custom palette that is closest to the given color.

getColorPalettePane

public ColorPalettePane getColorPalettePane()
Get the ColorPalettePane object used to edit the color palettes. This method only applies if isEditAllowed is true.
See Also:
isEditAllowed()

isColorInPalette

public static boolean isColorInPalette(TwoDModel palette,
                                       java.awt.Color c)
Return true if the given color is in the given palette.

setLocale

public void setLocale(java.util.Locale l)
Override to change the strings used in the ColorChoice.
Overrides:
setLocale in class java.awt.Component

addNotify

public void addNotify()
Overridden to update the strings used in the ColorChoice.
Overrides:
addNotify in class javax.swing.JComponent

removeNotify

public void removeNotify()
Overridden to take down the dropdown grid when the ColorChoice is taken out of the component hierarchy.
Overrides:
removeNotify in class javax.swing.JButton

updateUI

public void updateUI()
Override to update ui of buttons
Overrides:
updateUI in class javax.swing.JButton

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Override to return a new AccessibleContext.
Overrides:
getAccessibleContext in class javax.swing.JButton

firePropertyChange

protected void firePropertyChange(java.lang.String name,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Subclass so inner classes can access.
Overrides:
firePropertyChange in class javax.swing.JComponent

Oracle JEWT 4.2.10