FileDocCategorySizeDatePackage
SimpleModel.javaAPI DocExample2054Thu Oct 24 20:14:28 BST 2002None

SimpleModel

public class SimpleModel extends Object implements SimpleModelInterface

Fields Summary
protected transient ChangeEvent
changeEvent
protected EventListenerList
listenerList
private int
value
private boolean
activated
Constructors Summary
public SimpleModel()


       
public SimpleModel(int v)

 value = v; 
public SimpleModel(boolean b)

 activated = b; 
public SimpleModel(int v, boolean b)

 
        value = v;
        activated = b;
    
Methods Summary
public voidaddChangeListener(javax.swing.event.ChangeListener l)

        listenerList.add(ChangeListener.class, l);
    
protected voidfireChange()

        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()

        return (ChangeListener[])listenerList.getListeners(ChangeListener.class);
    
public intgetValue()

 return value; 
public booleanisActivated()

 return activated; 
public voidremoveChangeListener(javax.swing.event.ChangeListener l)

        listenerList.remove(ChangeListener.class, l);
    
public synchronized voidsetActivated(boolean b)

       if (b != activated) {
           activated = b;
           fireChange(); 
       }
    
public synchronized voidsetValue(int v)

       if (v != value) {
            value = v;
           fireChange(); 
       }
    
public java.lang.StringtoString()

        String modelString = "value=" + getValue() + ", " +
            "activated=" + isActivated();
        return getClass().getName() + "[" + modelString + "]";