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
53 *java.util.Observable()*
57 Construct an Observable with zero Observers.
60 *java.util.Observable.addObserver(Observer)*
62 public synchronized void addObserver(java.util.Observer o)
64 Adds an observer to the set of observers for this object, provided that it is
65 not the same as some observer already in the set. The order in which
66 notifications will be delivered to multiple observers is not specified. See the
69 o - an observer to be added.
71 *java.util.Observable.clearChanged()*
73 protected synchronized void clearChanged()
75 Indicates that this object has no longer changed, or that it has already
76 notified all of its observers of its most recent change, so that the hasChanged
77 method will now return false. This method is called automatically by the
78 notifyObservers methods.
81 *java.util.Observable.countObservers()*
83 public synchronized int countObservers()
85 Returns the number of observers of this Observable object.
88 Returns: the number of observers of this object.
89 *java.util.Observable.deleteObserver(Observer)*
91 public synchronized void deleteObserver(java.util.Observer o)
93 Deletes an observer from the set of observers of this object. Passing null to
94 this method will have no effect.
96 o - the observer to be deleted.
98 *java.util.Observable.deleteObservers()*
100 public synchronized void deleteObservers()
102 Clears the observer list so that this object no longer has any observers.
105 *java.util.Observable.hasChanged()*
107 public synchronized boolean hasChanged()
109 Tests if this object has changed.
112 Returns: true if and only if the setChanged method has been called more recently than
113 the clearChanged method on this object; false otherwise.
114 *java.util.Observable.notifyObservers()*
116 public void notifyObservers()
118 If this object has changed, as indicated by the hasChanged method, then notify
119 all of its observers and then call the clearChanged method to indicate that
120 this object has no longer changed.
122 Each observer has its update method called with two arguments: this observable
123 object and null. In other words, this method is equivalent to:
125 notifyObservers(null)
128 *java.util.Observable.notifyObservers(Object)*
130 public void notifyObservers(java.lang.Object arg)
132 If this object has changed, as indicated by the hasChanged method, then notify
133 all of its observers and then call the clearChanged method to indicate that
134 this object has no longer changed.
136 Each observer has its update method called with two arguments: this observable
137 object and the arg argument.
141 *java.util.Observable.setChanged()*
143 protected synchronized void setChanged()
145 Marks this Observable object as having been changed; the hasChanged method will