APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.colorchooser

public Class DefaultColorSelectionModel

extends Object
implements ColorSelectionModel, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.colorchooser.ColorSelectionModel
Annotations
@SuppressWarnings:serial
Imports
javax.swing.*, javax.swing.event.*, java.awt.Color, java.io.Serializable

A generic implementation of ColorSelectionModel.
Author
Steve Wilson
See Also
java.awt.Color

Field Summary

Modifier and TypeField and Description
protected transient ChangeEvent
changeEvent

Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property.

protected EventListenerList
listenerList

The listener list.

private Color

Constructor Summary

AccessConstructor and Description
public
DefaultColorSelectionModel()

Creates a DefaultColorSelectionModel with the current color set to Color.white.

public
DefaultColorSelectionModel(Color
the new Color
color
)

Creates a DefaultColorSelectionModel with the current color set to color, which should be non-null.

Method Summary

Modifier and TypeMethod and Description
public void
addChangeListener(ChangeListener
the ChangeListener to be added
l
)

Implements javax.swing.colorchooser.ColorSelectionModel.addChangeListener.

Adds a ChangeListener to the model.

protected void
fireStateChanged()

Runs each ChangeListener's stateChanged method.

public ChangeListener[]

Returns:

all of the ChangeListeners added, or an empty array if no listeners have been added
getChangeListeners
()

Returns an array of all the ChangeListeners added to this DefaultColorSelectionModel with addChangeListener.

public Color

Returns:

the selected Color
getSelectedColor
()

Implements javax.swing.colorchooser.ColorSelectionModel.getSelectedColor.

Returns the selected Color which should be non-null.

public void
removeChangeListener(ChangeListener
the ChangeListener to be removed
l
)

Implements javax.swing.colorchooser.ColorSelectionModel.removeChangeListener.

Removes a ChangeListener from the model.

public void
setSelectedColor(Color
the new Color
color
)

Implements javax.swing.colorchooser.ColorSelectionModel.setSelectedColor.

Sets the selected color to color.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changeEventback to summary
protected transient ChangeEvent changeEvent

Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".

listenerListback to summary
protected EventListenerList listenerList

The listener list.

selectedColorback to summary
private Color selectedColor

Constructor Detail

DefaultColorSelectionModelback to summary
public DefaultColorSelectionModel()

Creates a DefaultColorSelectionModel with the current color set to Color.white. This is the default constructor.

DefaultColorSelectionModelback to summary
public DefaultColorSelectionModel(Color color)

Creates a DefaultColorSelectionModel with the current color set to color, which should be non-null. Note that setting the color to null is undefined and may have unpredictable results.

Parameters
color:Color

the new Color

Method Detail

addChangeListenerback to summary
public void addChangeListener(ChangeListener l)

Implements javax.swing.colorchooser.ColorSelectionModel.addChangeListener.

Adds a ChangeListener to the model.

Parameters
l:ChangeListener

the ChangeListener to be added

fireStateChangedback to summary
protected void fireStateChanged()

Runs each ChangeListener's stateChanged method.

See Also
EventListenerList
getChangeListenersback to summary
public ChangeListener[] getChangeListeners()

Returns an array of all the ChangeListeners added to this DefaultColorSelectionModel with addChangeListener.

Returns:ChangeListener[]

all of the ChangeListeners added, or an empty array if no listeners have been added

Since
1.4
getSelectedColorback to summary
public Color getSelectedColor()

Implements javax.swing.colorchooser.ColorSelectionModel.getSelectedColor.

Returns the selected Color which should be non-null.

Returns:Color

the selected Color

removeChangeListenerback to summary
public void removeChangeListener(ChangeListener l)

Implements javax.swing.colorchooser.ColorSelectionModel.removeChangeListener.

Removes a ChangeListener from the model.

Parameters
l:ChangeListener

the ChangeListener to be removed

setSelectedColorback to summary
public void setSelectedColor(Color color)

Implements javax.swing.colorchooser.ColorSelectionModel.setSelectedColor.

Sets the selected color to color. Note that setting the color to null is undefined and may have unpredictable results. This method fires a state changed event if it sets the current color to a new non-null color; if the new color is the same as the current color, no event is fired.

Parameters
color:Color

the new Color