borland.jbcl Packages  borland.jbcl Class Hierarchy  borland.jbcl.control 

ColorChooserPanel component

java.lang.Object
   +----java.awt.Component
           +----java.awt.Container
                   +----java.awt.Panel
                           +----borland.jbcl.control.BevelPanel
                                   +----borland.jbcl.control.ColorChooserPanel

About the ColorChooserPanel component

Variables  Constructors  Properties  Methods  Event Listeners

Implements MenuContainer, AdjustmentListener, ItemListener, KeyListener, ImageObserver, Serializable, EventListener

Allows graphical selection of color values. You get the selected color by calling the getColorValue method. This component is a panel that contains controls for specifying a color. This component is the same as the ColorChooserDialog component, but ColorChooserDialog is used in the UI Designer, whereas this component is designed to be added to your own custom dialog or frame.

The Standard Colors list, number fields, and scroll bars are all interlocked; changing the setting of any type of control automatically updates the settings of the other types of controls.

After dropping a ColorChooserPanel onto the Component Tree or UI Designer, you generally need to set the frame property to "this". Otherwise, the dialog will not appear.

Relationship of the JBCL color chooser classes:


ColorChooserPanel variables

Variables implemented in this class

Variables implemented in borland.jbcl.control.BevelPanel

Variables implemented in java.awt.Component

ColorChooserPanel constructors

ColorChooserPanel properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in borland.jbcl.control.BevelPanel

Properties implemented in java.awt.Component

Properties implemented in java.awt.Container

Properties implemented in java.lang.Object

ColorChooserPanel methods

Methods implemented in this class

Methods implemented in borland.jbcl.control.BevelPanel

Methods implemented in java.awt.Component

Methods implemented in java.awt.Container

Methods implemented in java.awt.Panel

Methods implemented in java.lang.Object

ColorChooserPanel event listeners


ColorChooserPanel variables

CUSTOM_TAG

  public static final String CUSTOM_TAG = Res.getString(Res.CustomColorTag)
Enables you to add an item to the Standard Colors list.


ColorChooserPanel constructors

ColorChooserPanel()

  public ColorChooserPanel()
Creates a new color chooser panel with no color selected. Uses GridBagLayout.

ColorChooserPanel(java.awt.Color)

  public ColorChooserPanel(java.awt.Color value)
Creates a new color chooser panel with the specified color selected. Uses GridBagLayout.

Parameters:

value
The initially selected color.


ColorChooserPanel properties

changed

 public boolean isChanged()
The changed property keeps track of whether the selected color is different than the color that was initially selected when the dialog was opened.

colorValue

 public Color getColorValue()
 public void setColorValue(java.awt.Color value)
The colorValue property stores the value of the color. See Color.

hsbMode

 public void setHsbMode(boolean hsbMode)
The hsbMode property stores whether the color chooser dialog is in HSB mode. The property stores boolean true or false. If false, the dialog is in RGB mode. Labels the scrollbars "Hue, Saturation, Brightness" or "Red, Green, Blue", and makes their max value 100 (for HSB mode) or 255 (for RGB mode). Changes the displayed numerical color values between the equivalent HSB and RGB values.

preferredSize

 public Dimension getPreferredSize()
The PreferredSize property is the preferred size of the color chooser dialog box. The preferred size is used by layout managers to stretch out the scrollbars to a usable size.


ColorChooserPanel methods

changeColor(java.awt.Color)

  protected void changeColor(java.awt.Color value)
Calculates the new HSB and RGB values. Updates the number entry text fields with the new HSB and RGB values. Updates the positions of the scroll bar sliders. Changes the background color for the color sample.

Parameters:

value
The color value to change to.

changeColor(java.awt.Color, boolean, boolean)

  protected void changeColor(java.awt.Color value, boolean suppressText, boolean suppressScroll)
Calculates the new HSB and RGB values. Updates the number entry text fields with the new HSB and RGB values if requested. Updates the positions of the scroll bar sliders if requested. Changes the background color for the color sample.

Parameters:

value
The color value to change to.
suppressText
Whether to skip updating the text in the number entry value fields.
suppressScroll
Whether to skip updating the slider positions of the color-selection scroll bars.

colorChanged(java.awt.Color)

  protected void colorChanged(java.awt.Color newColor)
Causes the changed property to be set to true. This property indicates whether a color different than the initial color has been selected. The initial color is the color that was selected upon opening the color chooser panel.

Parameters:

newColor
The new color.

textToValue(java.lang.String, boolean)

  public static Color textToValue(java.lang.String text, boolean localized)
Updates the RGB or HSB values automatically when a standard named color is selected in the Standard Colors list.

Parameters:

text
The name of the selected color.

valueToText(java.awt.Color, boolean)

  public static String valueToText(java.awt.Color c, boolean localized)
Updates the Standard Colors list automatically when you change the RGB or HSB values in the Custom Color Settings group box to a combination. For example, if you manually enter Red = 255, Blue = 175, and Green = 175, the Standard Colors list will automatically show Pink as the selected item.

Parameters:

c
The value of the selected color.


ColorChooserPanel event listeners

This component is a source for the following event sets. For information on the standard AWT event sets, see Standard Java events.

component

 public synchronized void addComponentListener(java.awt.event.ComponentListener l)
 public synchronized void removeComponentListener(java.awt.event.ComponentListener l)

container

 public synchronized void addContainerListener(java.awt.event.ContainerListener l)
 public void removeContainerListener(java.awt.event.ContainerListener l)

focus

 public synchronized void addFocusListener(java.awt.event.FocusListener l)
 public synchronized void removeFocusListener(java.awt.event.FocusListener l)

key

 public synchronized void addKeyListener(java.awt.event.KeyListener l)
 public synchronized void removeKeyListener(java.awt.event.KeyListener l)

mouse

 public synchronized void addMouseListener(java.awt.event.MouseListener l)
 public synchronized void removeMouseListener(java.awt.event.MouseListener l)

mouseMotion

 public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener l)
 public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener l)