O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The JColorChooser Class

Properties

In addition to the typical UI properties of Swing components, the color chooser has the following properties listed in Table 12.6. The chooserPanels property contains an array of all the chooser panels currently associated with this color chooser. You can get and set the entire array at once or, more commonly, you can add and remove chooser panels using some of the methods described later. The color property contains the currently selected color in the chooser. The previewPanel property contains the JComponent subclass that previews your color choice. (You can see an example of the default preview panel in Figure 12.7.) The selectionModel property dictates which selection model the chooser uses.

Table 12-6. JColorChooser Properties

Property

Data Type

get

is

set

bound

Default Value

See also properties from the JComponent class (Table 3.5)       

UI

ColorChooserUI

•

 

•

•

from L&F

UIClassID*

String

•

   

"ColorChooserUI"

selectionModel

ColorSelectionModel

•

 

•

•

DefaultColorSelectionModel

accessibleContext

AccessibleContext

•

   

JColorChooser.AccessibleJColorChooser()

chooserPanels

AbstractColorChooserPanel[]

•

 

•

•

null

color

Color

•

 

•

 

Color.white

previewPanel

JComponent

•

 

•

•

null

Events (Inherited from JComponent)

On its own, JColorChooser only supports PropertyChangeEvents, like all ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required