KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > AbstractSpinnerModel


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: AbstractSpinnerModel.java,v $
11    Revision 1.1 2004/04/18 14:21:50 bobintetley
12    JSpinner implementation
13
14
15 */

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