java.lang.Object | |
↳ | java.util.Observable |
Known Direct Subclasses |
Observable is used to notify a group of Observer objects when a change
occurs. On creation, the set of observers is empty. After a change occurred,
the application can call the notifyObservers()
method. This will
cause the invocation of the update()
method of all registered
Observers. The order of invocation is not specified. This implementation will
call the Observers in the order they registered. Subclasses are completely
free in what order they call the update methods.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
Observable object. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified observer to the list of observers.
| |||||||||||
Returns the number of observers registered to this
Observable . | |||||||||||
Removes the specified observer from the list of observers.
| |||||||||||
Removes all observers from the list of observers.
| |||||||||||
Returns the changed flag for this
Observable . | |||||||||||
If
hasChanged() returns true , calls the update()
method for every observer in the list of observers using null as the
argument. | |||||||||||
If
hasChanged() returns true , calls the update()
method for every Observer in the list of observers using the specified
argument. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Clears the changed flag for this
Observable . | |||||||||||
Sets the changed flag for this
Observable . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Adds the specified observer to the list of observers. If it is already registered, it is not added a second time.
observer | the Observer to add. |
---|
Returns the number of observers registered to this Observable
.
Removes the specified observer from the list of observers. Passing null won't do anything.
observer | the observer to remove. |
---|
Removes all observers from the list of observers.
Returns the changed flag for this Observable
.
true
when the changed flag for this Observable
is
set, false
otherwise.
If hasChanged()
returns true
, calls the update()
method for every observer in the list of observers using null as the
argument. Afterwards, calls clearChanged()
.
Equivalent to calling notifyObservers(null)
.
If hasChanged()
returns true
, calls the update()
method for every Observer in the list of observers using the specified
argument. Afterwards calls clearChanged()
.
data | the argument passed to update() .
|
---|
Clears the changed flag for this Observable
. After calling
clearChanged()
, hasChanged()
will return false
.
Sets the changed flag for this Observable
. After calling
setChanged()
, hasChanged()
will return true
.