![]() |
![]() |
![]() |
![]() |
![]() |
|
Observers are instances of a class that
implements the Observer interface defined in the java.util
package. That interface requires the class to define an update
method, which is called whenever the observer is activated by a connected
model.
In the following preview of an embedded update definition, the
update method fetches a rating and title from a movie and uses that
rating and title to set the value and title displayed by a meter. The
arguments happen to be ignored:
public void update (Observable observable, Object object) {
getMeter().setValue(getMovie().rating());
getMeter().setTitle(getMovie().getTitle());
}