Intent
One object changes state, all of its dependents are updated automatically.
Where to use & benefits
- One change affects one or many objects.
- Many object behavior depends on one object state.
- Need broadcast communication.
- Maintain consistency between objects
- keep classes from becoming too tightly coupled, which would hamper reusability.
Structure

Participants
Subject (Not used)
knows its observers. Any number of Observer objects may observe a subject and provides an interface for attaching and detaching Observer objects.
ConcreteSubject (java.awt.Button)
stores state of interest to ConcreteObserver and sends a notification to its observers when its state changes
Observer (java.awt.event.ActionListner)
defines an updating interface for objects that should be notified of changes in a subject.
ConcreteObserver (MainApplet)
- maintains a reference to a ConcreteSubject object
- stores state that should stay consistent with the subject's
- implements the Observer updating interface to keep its state consistent with the subject's
Example
In the demonstration application, the applet GUI components (Button, List) are register with the ActionListner interface to handle the user events. When user performs operation (like clicking the button), the respective method actionPerformed(ActionEvent evt) is invoked in the MainApplet class.
Class Diagram
