java.util
Class Observable

java.lang.Object
  |
  +--java.util.Observable

public class Observable
extends Object

This class should be subclassed by observable object, or "data" in the Model-View paradigm. An Observable object may have any number of Observers. Whenever the Observable instance changes, it notifies all of its observers. Notification is done by calling the update() method on all observers.


Constructor Summary
Observable()
           
 
Method Summary
 void addObserver(Observer o)
          Adds an observer to the observer list.
protected  void clearChanged()
          Clears an observable change.
 int countObservers()
          Counts the number of observers.
 void deleteObserver(Observer o)
          Deletes an observer from the observer list.
 void deleteObservers()
          Deletes observers from the observer list.
 boolean hasChanged()
          Returns a true boolean if an observable change has occurred.
 void notifyObservers()
          Notifies all observers if an observable change occurs.
 void notifyObservers(Object arg)
          Notifies all observers of the specified observable change which occurred.
protected  void setChanged()
          Sets a flag to note an observable change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Observable

public Observable()
Method Detail

addObserver

public void addObserver(Observer o)
Adds an observer to the observer list.

Parameters:
o - the observer to be added

deleteObserver

public void deleteObserver(Observer o)
Deletes an observer from the observer list.

Parameters:
o - the observer to be deleted

notifyObservers

public void notifyObservers()
Notifies all observers if an observable change occurs.


notifyObservers

public void notifyObservers(Object arg)
Notifies all observers of the specified observable change which occurred.

Parameters:
arg - what is being notified

deleteObservers

public void deleteObservers()
Deletes observers from the observer list.


setChanged

protected void setChanged()
Sets a flag to note an observable change.


clearChanged

protected void clearChanged()
Clears an observable change.


hasChanged

public boolean hasChanged()
Returns a true boolean if an observable change has occurred.


countObservers

public int countObservers()
Counts the number of observers.