link >
Guidelines Home Page >  Java Look and Feel Design Guidelines
>
Part III: The Components of the Java Foundation Classes
>
8: Dialog Boxes and Alert Boxes
>
Color Choosers
  Previous Next Contents/Index/Search


Color Choosers

A color chooser provides one or more content panes from which users can select colors and a preview mechanism by which users can view the selected colors in context. You can display a color chooser in a dialog box, as shown in the following figure. The three command buttons (OK, Cancel, and Help) are part of the dialog box, not the color chooser. (A color chooser can also be implemented in a multiple-use dialog box.)

Figure 120   JFC-Supplied Color Chooser

 

Color Chooser

As supplied by the JFC, the color chooser offers users three methods for selecting a color:

  • Swatches. Users can select a color from a palette (as shown in the preceding figure).
  • HSB. Users can choose the hue, saturation, and brightness values for a color.
  • RGB. Users can choose the red, green, and blue values for a color.

In addition, the color chooser offers a preview panel within the dialog box.

If your application requires a different method for choosing colors, you can add a content pane with that feature. You can also remove existing content panes. If you use only one content pane, the tabs disappear. In addition, you can specify your own preview panel or alter the supplied one.

  The color chooser is a panel. The color panel can be inserted in a dialog box by using the JDialog container. This operation is accomplished with the static method CreateDialog on the JColorChooser container. Alternately, this can be done with the ShowDialog method, which creates, displays, and dismisses the dialog box.


Java Look and Feel Design Guidelines, second edition.
Copyright 1994-2004 Sun Microsystems, Inc. All Rights Reserved.
Previous Next Contents/Index/Search
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
JavaOne Banner Java 8 banner (182)