javax.swing.colorchooser
Class DefaultColorSelectionModel

java.lang.Object
  extended by javax.swing.colorchooser.DefaultColorSelectionModel
All Implemented Interfaces:
Serializable, ColorSelectionModel

public class DefaultColorSelectionModel
extends Object
implements ColorSelectionModel, Serializable

This is the default implementation of the ColorSelectionModel interface that JColorChoosers use.

See Also:
Serialized Form

Field Summary
protected  ChangeEvent changeEvent
          The ChangeEvent fired to all ChangeListeners.
protected  EventListenerList listenerList
          The list of listeners.
 
Constructor Summary
DefaultColorSelectionModel()
          Creates a new color selection model with the default white color.
DefaultColorSelectionModel(Color color)
          Creates a new color selection model with a given selected color.
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Adds a listener to this model.
protected  void fireStateChanged()
          Calls all the stateChanged() method of all added ChangeListener objects with changeEvent as argument.
 ChangeListener[] getChangeListeners()
          Returns all currently added ChangeListener objects.
 Color getSelectedColor()
          Returns the selected color.
 void removeChangeListener(ChangeListener listener)
          Removes a listener from this model.
 void setSelectedColor(Color color)
          This method sets the color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeEvent

protected transient ChangeEvent changeEvent
The ChangeEvent fired to all ChangeListeners.


listenerList

protected EventListenerList listenerList
The list of listeners.

Constructor Detail

DefaultColorSelectionModel

public DefaultColorSelectionModel()
Creates a new color selection model with the default white color.


DefaultColorSelectionModel

public DefaultColorSelectionModel(Color color)
Creates a new color selection model with a given selected color.

Parameters:
color - The initial color.
Throws:
Error - If the color is null.
Method Detail

getSelectedColor

public Color getSelectedColor()
Returns the selected color.

Specified by:
getSelectedColor in interface ColorSelectionModel
Returns:
The selected color.

setSelectedColor

public void setSelectedColor(Color color)
This method sets the color.

Specified by:
setSelectedColor in interface ColorSelectionModel
Parameters:
color - The color to set.
Throws:
Error - If the color is set.

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener to this model.

Specified by:
addChangeListener in interface ColorSelectionModel
Parameters:
listener - The listener to add.

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes a listener from this model.

Specified by:
removeChangeListener in interface ColorSelectionModel
Parameters:
listener - The listener to remove.

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns all currently added ChangeListener objects.

Returns:
Array of ChangeListener objects.

fireStateChanged

protected void fireStateChanged()
Calls all the stateChanged() method of all added ChangeListener objects with changeEvent as argument.