|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
public class Observable
This class represents an object which is observable. Other objects may
register their intent to be notified when this object changes; and when
this object does change, it will trigger the update
method
of each observer.
Note that the notifyObservers()
method of this class is
unrelated to the notify()
of Object.
Observer
Constructor Summary | |
---|---|
Observable()
Constructs an Observable with zero Observers. |
Method Summary | |
---|---|
void |
addObserver(Observer observer)
Adds an Observer. |
protected void |
clearChanged()
Reset this Observable's state to unchanged. |
int |
countObservers()
Returns the number of observers for this object. |
void |
deleteObserver(Observer victim)
Deletes an Observer of this Observable. |
void |
deleteObservers()
Deletes all Observers of this Observable. |
boolean |
hasChanged()
True if setChanged has been called more recently than
clearChanged . |
void |
notifyObservers()
If the Observable has actually changed then tell all Observers about it, then reset state to unchanged. |
void |
notifyObservers(Object obj)
If the Observable has actually changed then tell all Observers about it, then reset state to unchanged. |
protected void |
setChanged()
Marks this Observable as having changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Observable()
Method Detail |
---|
public void addObserver(Observer observer)
observer
- Observer to add
NullPointerException
- if observer is nullprotected void clearChanged()
notifyObservers
once all observers have been notified.
notifyObservers()
public int countObservers()
public void deleteObserver(Observer victim)
victim
- Observer to deletepublic void deleteObservers()
public boolean hasChanged()
setChanged
has been called more recently than
clearChanged
.
public void notifyObservers()
notifyObservers(Object)
,
Observer.update(Observable, Object)
public void notifyObservers(Object obj)
obj
- argument to Observer's update methodObserver.update(Observable, Object)
protected void setChanged()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |