- java.lang.Object
-
- javax.swing.DefaultSingleSelectionModel
-
- All Implemented Interfaces:
- Serializable, SingleSelectionModel
public class DefaultSingleSelectionModel extends Object implements SingleSelectionModel, Serializable
A generic implementation of SingleSelectionModel.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the
java.beanspackage. Please seeXMLEncoder.
-
-
Field Summary
Fields Modifier and Type Field and Description protected ChangeEventchangeEventprotected EventListenerListlistenerListThe collection of registered listeners
-
Constructor Summary
Constructors Constructor and Description DefaultSingleSelectionModel()
-
Method Summary
Methods Modifier and Type Method and Description voidaddChangeListener(ChangeListener l)Adds aChangeListenerto the button.voidclearSelection()Clears the selection (to -1).protected voidfireStateChanged()Notifies all listeners that have registered interest for notification on this event type.ChangeListener[]getChangeListeners()Returns an array of all the change listeners registered on thisDefaultSingleSelectionModel.<T extends EventListener>
T[]getListeners(Class<T> listenerType)Returns an array of all the objects currently registered asFooListeners upon this model.intgetSelectedIndex()Returns the model's selection.booleanisSelected()Returns true if the selection model currently has a selected value.voidremoveChangeListener(ChangeListener l)Removes aChangeListenerfrom the button.voidsetSelectedIndex(int index)Sets the model's selected index to index.
-
-
-
Field Detail
-
changeEvent
protected transient ChangeEvent changeEvent
-
listenerList
protected EventListenerList listenerList
The collection of registered listeners
-
-
Method Detail
-
getSelectedIndex
public int getSelectedIndex()
Description copied from interface:SingleSelectionModelReturns the model's selection.- Specified by:
getSelectedIndexin interfaceSingleSelectionModel- Returns:
- the model's selection, or -1 if there is no selection
- See Also:
SingleSelectionModel.setSelectedIndex(int)
-
setSelectedIndex
public void setSelectedIndex(int index)
Description copied from interface:SingleSelectionModelSets the model's selected index to index. Notifies any listeners if the model changes- Specified by:
setSelectedIndexin interfaceSingleSelectionModel- Parameters:
index- an int specifying the model selection- See Also:
SingleSelectionModel.getSelectedIndex(),SingleSelectionModel.addChangeListener(javax.swing.event.ChangeListener)
-
clearSelection
public void clearSelection()
Description copied from interface:SingleSelectionModelClears the selection (to -1).- Specified by:
clearSelectionin interfaceSingleSelectionModel
-
isSelected
public boolean isSelected()
Description copied from interface:SingleSelectionModelReturns true if the selection model currently has a selected value.- Specified by:
isSelectedin interfaceSingleSelectionModel- Returns:
- true if a value is currently selected
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds aChangeListenerto the button.- Specified by:
addChangeListenerin interfaceSingleSelectionModel- Parameters:
l- the ChangeListener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes aChangeListenerfrom the button.- Specified by:
removeChangeListenerin interfaceSingleSelectionModel- Parameters:
l- the ChangeListener to remove
-
getChangeListeners
public ChangeListener[] getChangeListeners()
Returns an array of all the change listeners registered on thisDefaultSingleSelectionModel.- Returns:
- all of this model's
ChangeListeners or an empty array if no change listeners are currently registered - Since:
- 1.4
- See Also:
addChangeListener(javax.swing.event.ChangeListener),removeChangeListener(javax.swing.event.ChangeListener)
-
fireStateChanged
protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.- See Also:
EventListenerList
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListeners upon this model.FooListeners are registered using theaddFooListenermethod.You can specify the
listenerTypeargument with a class literal, such asFooListener.class. For example, you can query aDefaultSingleSelectionModelinstancemfor its change listeners with the following code:ChangeListener[] cls = (ChangeListener[])(m.getListeners(ChangeListener.class));
If no such listeners exist, this method returns an empty array.- Parameters:
listenerType- the type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener- Returns:
- an array of all objects registered as
FooListeners on this model, or an empty array if no such listeners have been added - Throws:
ClassCastException- iflistenerTypedoesn't specify a class or interface that implementsjava.util.EventListener- Since:
- 1.3
- See Also:
getChangeListeners()
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/defaultsingleselectionmodel.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.