public class Observable
extends java.lang.Object
Constructor and Description |
---|
Observable()
Creates a new instance without registered observers.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Observer observer)
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
|
int |
countObservers()
Returns the number of observers of this Observable object.
|
void |
deleteObserver(Observer observer)
Deletes an observer from the set of observers of this object.
|
void |
deleteObservers()
Clears the observer list so that this object no longer has any observers.
|
boolean |
hasChanged()
Tests if this object has changed.
|
void |
notifyObservers()
This method is equivalent to
notifyObservers(null, false) |
void |
notifyObservers(java.lang.Object object)
If this object has changed, as indicated by the hasChanged method, then notify all of its
observers and then call the clearChanged method to indicate that this object has no longer changed.
|
void |
notifyObservers(java.lang.Object object,
boolean setChanged)
This method is a shortcut to change the object changed status and call the notification method.
|
public Observable()
public void notifyObservers()
notifyObservers(null, false)
public void notifyObservers(java.lang.Object object)
public void notifyObservers(java.lang.Object object, boolean setChanged)
public void addObserver(Observer observer)
observer
- an observer to be added.public void deleteObserver(Observer observer)
observer
- the observer to be deleted.public void deleteObservers()
public int countObservers()
public boolean hasChanged()