Class Observable
 An observable object can have one or more observers. An observer
 may be any object that implements interface Observer. After an
 observable instance changes, an application calling the
 Observable's notifyObservers method
 causes all of its observers to be notified of the change by a call
 to their update method.
 
The order in which notifications will be delivered is unspecified. The default implementation provided in the Observable class will notify Observers in the order in which they registered interest, but subclasses may change this order, use no guaranteed order, deliver notifications on separate threads, or may guarantee that their subclass follows this order, as they choose.
 Note that this notification mechanism has nothing to do with threads
 and is completely separate from the wait and notify
 mechanism of class Object.
 
 When an observable object is newly created, its set of observers is
 empty. Two observers are considered the same if and only if the
 equals method returns true for them.
- Since:
- 1.0
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidDeprecated.Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set.protected voidDeprecated.Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that thehasChangedmethod will now returnfalse.intDeprecated.Returns the number of observers of thisObservableobject.voidDeprecated.Deletes an observer from the set of observers of this object.voidDeprecated.Clears the observer list so that this object no longer has any observers.booleanDeprecated.Tests if this object has changed.voidDeprecated.If this object has changed, as indicated by thehasChangedmethod, then notify all of its observers and then call theclearChangedmethod to indicate that this object has no longer changed.voidnotifyObservers(Object arg) Deprecated.If this object has changed, as indicated by thehasChangedmethod, then notify all of its observers and then call theclearChangedmethod to indicate that this object has no longer changed.protected voidDeprecated.Marks thisObservableobject as having been changed; thehasChangedmethod will now returntrue.
- 
Constructor Details- 
Observablepublic Observable()Deprecated.Construct an Observable with zero Observers.
 
- 
- 
Method Details- 
addObserverDeprecated.Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.- Parameters:
- o- an observer to be added.
- Throws:
- NullPointerException- if the parameter o is null.
 
- 
deleteObserverDeprecated.Deletes an observer from the set of observers of this object. Passingnullto this method will have no effect.- Parameters:
- o- the observer to be deleted.
 
- 
notifyObserverspublic void notifyObservers()Deprecated.If this object has changed, as indicated by thehasChangedmethod, then notify all of its observers and then call theclearChangedmethod to indicate that this object has no longer changed.Each observer has its updatemethod called with two arguments: this observable object andnull. In other words, this method is equivalent to:notifyObservers(null)- See Also:
 
- 
notifyObserversDeprecated.If this object has changed, as indicated by thehasChangedmethod, then notify all of its observers and then call theclearChangedmethod to indicate that this object has no longer changed.Each observer has its updatemethod called with two arguments: this observable object and theargargument.- Parameters:
- arg- any object.
- See Also:
 
- 
deleteObserverspublic void deleteObservers()Deprecated.Clears the observer list so that this object no longer has any observers.
- 
setChangedprotected void setChanged()Deprecated.Marks thisObservableobject as having been changed; thehasChangedmethod will now returntrue.
- 
clearChangedprotected void clearChanged()Deprecated.Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change, so that thehasChangedmethod will now returnfalse. This method is called automatically by thenotifyObserversmethods.- See Also:
 
- 
hasChangedpublic boolean hasChanged()Deprecated.Tests if this object has changed.- Returns:
- trueif and only if the- setChangedmethod has been called more recently than the- clearChangedmethod on this object;- falseotherwise.
- See Also:
 
- 
countObserverspublic int countObservers()Deprecated.Returns the number of observers of thisObservableobject.- Returns:
- the number of observers of this object.
 
 
- 
Observerinterface have been deprecated. The event model supported byObserverandObservableis quite limited, the order of notifications delivered byObservableis unspecified, and state changes are not in one-for-one correspondence with notifications. For a richer event model, consider using thejava.beanspackage. For reliable and ordered messaging among threads, consider using one of the concurrent data structures in thejava.util.concurrentpackage. For reactive streams style programming, see theFlowAPI.