borland Packages  Class Hierarchy  jbcl.control Package  Index 

ColorChooserPanel component

java.lang.Object
   +----java.awt.Component
           +----java.awt.Container
                   +----com.sun.java.swing.JComponent
                           +----borland.jbcl.view.BeanPanel
                                   +----borland.jbcl.control.BevelPanel
                                           +----borland.jbcl.control.ColorChooserPanel

About the ColorChooserPanel component

Variables  Constructors  Properties  Methods  Event Listeners

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

The ColorChooserPanel component enables the user to select colors visually or to specify color values numerically. You can add ColorChooserPanel to a custom frame or dialog box to give your users the capability of easy color selection.

If you want to have the user select colors within a dialog box, use the ColorChooser component on the Component Palette. It presents the color chooser panel within a dialog box.

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.

To change the selected color in the color panel at runtime, call one of the changeColor() methods. The textToValue() method converts a String to a Color object. The valueToText() method converts a Color object to a String.

You can add a custom color to the Standard Colors list using the CUSTOM_TAG variable.


ColorChooserPanel variables

Variables implemented in this class

Variables implemented in borland.jbcl.control.BevelPanel

Variables implemented in borland.jbcl.view.BeanPanel

Variables implemented in com.sun.java.swing.JComponent

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 borland.jbcl.view.BeanPanel

Properties implemented in com.sun.java.swing.JComponent

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 borland.jbcl.view.BeanPanel

Methods implemented in com.sun.java.swing.JComponent

Methods implemented in java.awt.Component

Methods implemented in java.awt.Container

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()
Read-only property that 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)
Stores the value of the color. See Color.

hsbMode

 public boolean isHsbMode()
 public void setHsbMode(boolean hsbMode)
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 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

addNotify()

  public void addNotify()

Overrides: borland.jbcl.view.BeanPanel.addNotify()

changeColor(java.awt.Color)

  protected void changeColor(java.awt.Color value)
Changes the selected color to the color specified with the value parameter. changeColor() 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, and 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.
localized
If true, the resulting Color is localized; if false, it isn't.

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.
localized
If true, the resulting color string is localized; if false, it isn't.


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.

action

 public synchronized void addActionListener(java.awt.event.ActionListener l)
 public synchronized void removeActionListener(java.awt.event.ActionListener l)

ancestor

 public void addAncestorListener(com.sun.java.swing.event.AncestorListener )
 public void removeAncestorListener(com.sun.java.swing.event.AncestorListener )

component

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

container

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

focus

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

key

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

mouse

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

mouseMotion

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

propertyChange

 public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener )
 public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )

vetoableChange

 public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener )
 public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )