14.8. The JColorChooser Component
JColorChooser is a component that is new to Swing; the AWT has no equivalent. JColorChooser lets the user interactively select a Color. The default behavior is to present a dialog box containing a tabbed pane by which the user chooses the color through swatches, HSB (hue, saturation, brightness) values, or RGB values.
The simplest use is to call JColorChooser.showDialog, supplying parent Component as the first argument, the title as the second argument, and the initial color selection as the third argument, for example,
JColorChooser.showDialog
(parent, "Select Background", getBackground());
The dialog presents an OK, Cancel, and Reset button as shown in Figure 14-11. If the user selects OK, the return value ...
Get Core Web Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.