FileDocCategorySizeDatePackage
AbstractSpinnerModel.javaAPI DocJava SE 5 API3691Fri Aug 26 14:57:52 BST 2005javax.swing

AbstractSpinnerModel

public abstract class AbstractSpinnerModel extends Object implements SpinnerModel
This class provides the ChangeListener part of the SpinnerModel interface that should be suitable for most concrete SpinnerModel implementations. Subclasses must provide an implementation of the minimum, maximum, and value properties and the getNextValue and getPreviousValue methods.
see
JSpinner
see
SpinnerModel
see
SpinnerListModel
see
SpinnerNumberModel
see
SpinnerDateModel
version
1.7 05/05/04
author
Hans Muller
since
1.4

Fields Summary
private 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".
protected EventListenerList
listenerList
The list of ChangeListeners for this model. Subclasses may store their own listeners here.
Constructors Summary
Methods Summary
public voidaddChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the model's listener list. The ChangeListeners must be notified when the models value changes.

param
l the ChangeListener to add
see
#removeChangeListener
see
SpinnerModel#addChangeListener



                                       
        
        listenerList.add(ChangeListener.class, l);
    
protected voidfireStateChanged()
Run each ChangeListeners stateChanged() method.

see
#setValue
see
EventListenerList

        Object[] listeners = listenerList.getListenerList();
        for (int i = listeners.length - 2; i >= 0; i -=2 ) {
            if (listeners[i] == ChangeListener.class) {
                if (changeEvent == null) {
                    changeEvent = new ChangeEvent(this);
                }
                ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
            }          
        }
    
public javax.swing.event.ChangeListener[]getChangeListeners()
Returns an array of all the ChangeListeners added to this AbstractSpinnerModel with addChangeListener().

return
all of the ChangeListeners added or an empty array if no listeners have been added
since
1.4

        return (ChangeListener[])listenerList.getListeners(
                ChangeListener.class);
    
public T[]getListeners(java.lang.Class listenerType)
Return an array of all the listeners of the given type that were added to this model. For example to find all of the ChangeListeners added to this model:
myAbstractSpinnerModel.getListeners(ChangeListener.class);

param
listenerType the type of listeners to return, e.g. ChangeListener.class
return
all of the objects receiving listenerType notifications from this model

 
	return listenerList.getListeners(listenerType); 
    
public voidremoveChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the model's listener list.

param
l the ChangeListener to remove
see
#addChangeListener
see
SpinnerModel#removeChangeListener

        listenerList.remove(ChangeListener.class, l);