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 ...

Get Java Swing 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.