- java.lang.Object
-
- javax.swing.colorchooser.DefaultColorSelectionModel
-
- All Implemented Interfaces:
- Serializable, ColorSelectionModel
public class DefaultColorSelectionModel extends Object implements ColorSelectionModel, Serializable
A generic implementation ofColorSelectionModel
.- See Also:
Color
-
-
Field Summary
Fields Modifier and Type Field and Description protected ChangeEvent
changeEvent
Only oneChangeEvent
is needed per model instance since the event's only (read-only) state is the source property.protected EventListenerList
listenerList
-
Constructor Summary
Constructors Constructor and Description DefaultColorSelectionModel()
Creates aDefaultColorSelectionModel
with the current color set toColor.white
.DefaultColorSelectionModel(Color color)
Creates aDefaultColorSelectionModel
with the current color set tocolor
, which should be non-null
.
-
Method Summary
Methods Modifier and Type Method and Description void
addChangeListener(ChangeListener l)
Adds aChangeListener
to the model.protected void
fireStateChanged()
Runs eachChangeListener
'sstateChanged
method.ChangeListener[]
getChangeListeners()
Returns an array of all theChangeListener
s added to thisDefaultColorSelectionModel
withaddChangeListener
.Color
getSelectedColor()
Returns the selectedColor
which should be non-null
.void
removeChangeListener(ChangeListener l)
Removes aChangeListener
from the model.void
setSelectedColor(Color color)
Sets the selected color tocolor
.
-
-
-
Field Detail
-
changeEvent
protected transient ChangeEvent changeEvent
Only oneChangeEvent
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".
-
listenerList
protected EventListenerList listenerList
-
-
Constructor Detail
-
DefaultColorSelectionModel
public DefaultColorSelectionModel()
Creates aDefaultColorSelectionModel
with the current color set toColor.white
. This is the default constructor.
-
DefaultColorSelectionModel
public DefaultColorSelectionModel(Color color)
Creates aDefaultColorSelectionModel
with the current color set tocolor
, which should be non-null
. Note that setting the color tonull
is undefined and may have unpredictable results.- Parameters:
color
- the newColor
-
-
Method Detail
-
getSelectedColor
public Color getSelectedColor()
Returns the selectedColor
which should be non-null
.- Specified by:
getSelectedColor
in interfaceColorSelectionModel
- Returns:
- the selected
Color
- See Also:
ColorSelectionModel.setSelectedColor(java.awt.Color)
-
setSelectedColor
public void setSelectedColor(Color color)
Sets the selected color tocolor
. Note that setting the color tonull
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.- Specified by:
setSelectedColor
in interfaceColorSelectionModel
- Parameters:
color
- the newColor
- See Also:
ColorSelectionModel.getSelectedColor()
,ColorSelectionModel.addChangeListener(javax.swing.event.ChangeListener)
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds aChangeListener
to the model.- Specified by:
addChangeListener
in interfaceColorSelectionModel
- Parameters:
l
- theChangeListener
to be added
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes aChangeListener
from the model.- Specified by:
removeChangeListener
in interfaceColorSelectionModel
- Parameters:
l
- theChangeListener
to be removed
-
getChangeListeners
public ChangeListener[] getChangeListeners()
Returns an array of all theChangeListener
s added to thisDefaultColorSelectionModel
withaddChangeListener
.- Returns:
- all of the
ChangeListener
s added, or an empty array if no listeners have been added - Since:
- 1.4
-
fireStateChanged
protected void fireStateChanged()
Runs eachChangeListener
'sstateChanged
method.- See Also:
EventListenerList
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
23/11/2024 01:01:57 Cette version de la page est en cache (à la date du 23/11/2024 01:01:57) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 07/12/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/colorchooser/defaultcolorselectionmodel.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.