1 *java.util.Observable* *Observable* This class represents an observable object,
3 public class Observable
4 extends |java.lang.Object|
6 |java.util.Observable_Description|
7 |java.util.Observable_Fields|
8 |java.util.Observable_Constructors|
9 |java.util.Observable_Methods|
11 ================================================================================
13 *java.util.Observable_Constructors*
14 |java.util.Observable()|Construct an Observable with zero Observers.
16 *java.util.Observable_Methods*
17 |java.util.Observable.addObserver(Observer)|Adds an observer to the set of obse
18 |java.util.Observable.clearChanged()|Indicates that this object has no longer c
19 |java.util.Observable.countObservers()|Returns the number of observers of this
20 |java.util.Observable.deleteObserver(Observer)|Deletes an observer from the set
21 |java.util.Observable.deleteObservers()|Clears the observer list so that this o
22 |java.util.Observable.hasChanged()|Tests if this object has changed.
23 |java.util.Observable.notifyObservers()|If this object has changed, as indicate
24 |java.util.Observable.notifyObservers(Object)|If this object has changed, as in
25 |java.util.Observable.setChanged()|Marks this Observable object as having been
27 *java.util.Observable_Description*
29 This class represents an observable object, or "data" in the model-view
30 paradigm. It can be subclassed to represent an object that the application
31 wants to have observed.
33 An observable object can have one or more observers. An observer may be any
34 object that implements interface Observer. After an observable instance
35 changes, an application calling the Observable's notifyObservers method causes
36 all of its observers to be notified of the change by a call to their update
39 The order in which notifications will be delivered is unspecified. The default
40 implementation provided in the Observable class will notify Observers in the
41 order in which they registered interest, but subclasses may change this order,
42 use no guaranteed order, deliver notifications on separate threads, or may
43 guarantee that their subclass follows this order, as they choose.
45 Note that this notification mechanism is has nothing to do with threads and is
46 completely separate from the wait and notify mechanism of class Object.
48 When an observable object is newly created, its set of observers is empty. Two
49 observers are considered the same if and only if the equals method returns true
54 *java.util.Observable()*
58 Construct an Observable with zero Observers.
61 *java.util.Observable.addObserver(Observer)*
63 public synchronized void addObserver(java.util.Observer o)
65 Adds an observer to the set of observers for this object, provided that it is
66 not the same as some observer already in the set. The order in which
67 notifications will be delivered to multiple observers is not specified. See the
71 o - an observer to be added.
73 *java.util.Observable.clearChanged()*
75 protected synchronized void clearChanged()
77 Indicates that this object has no longer changed, or that it has already
78 notified all of its observers of its most recent change, so that the hasChanged
79 method will now return false. This method is called automatically by the
80 notifyObservers methods.
84 *java.util.Observable.countObservers()*
86 public synchronized int countObservers()
88 Returns the number of observers of this Observable object.
92 Returns: the number of observers of this object.
94 *java.util.Observable.deleteObserver(Observer)*
96 public synchronized void deleteObserver(java.util.Observer o)
98 Deletes an observer from the set of observers of this object. Passing null to
99 this method will have no effect.
102 o - the observer to be deleted.
104 *java.util.Observable.deleteObservers()*
106 public synchronized void deleteObservers()
108 Clears the observer list so that this object no longer has any observers.
112 *java.util.Observable.hasChanged()*
114 public synchronized boolean hasChanged()
116 Tests if this object has changed.
120 Returns: true if and only if the setChanged method has been called more recently than
121 the clearChanged method on this object; false otherwise.
123 *java.util.Observable.notifyObservers()*
125 public void notifyObservers()
127 If this object has changed, as indicated by the hasChanged method, then notify
128 all of its observers and then call the clearChanged method to indicate that
129 this object has no longer changed.
131 Each observer has its update method called with two arguments: this observable
132 object and null. In other words, this method is equivalent to:
134 notifyObservers(null)
138 *java.util.Observable.notifyObservers(Object)*
140 public void notifyObservers(java.lang.Object arg)
142 If this object has changed, as indicated by the hasChanged method, then notify
143 all of its observers and then call the clearChanged method to indicate that
144 this object has no longer changed.
146 Each observer has its update method called with two arguments: this observable
147 object and the arg argument.
152 *java.util.Observable.setChanged()*
154 protected synchronized void setChanged()
156 Marks this Observable object as having been changed; the hasChanged method will