1 16 17 package swingwtx.swing; 18 19 import swingwtx.swing.event.*; 20 21 import java.util.*; 22 23 public abstract class AbstractSpinnerModel implements SpinnerModel { 24 25 protected Vector listeners = new Vector(); 26 27 public void addChangeListener(ChangeListener l) { 28 listeners.add(l); 29 } 30 31 public void removeChangeListener(ChangeListener l) { 32 listeners.remove(l); 33 } 34 35 public ChangeListener[] getChangeListeners() { 36 ChangeListener[] cl = new ChangeListener[listeners.size()]; 37 for (int i = 0; i < listeners.size(); i++) 38 cl[i] = (ChangeListener) listeners.get(i); 39 return cl; 40 } 41 42 43 protected void fireStateChanged() { 44 for (int i = 0; i < listeners.size(); i++) 45 ((ChangeListener) listeners.get(i)).stateChanged(new ChangeEvent(this)); 46 } 47 48 } 49 50 51 | Popular Tags |