Observer Observable

see also Java Idioms


Observer Observable is Java's implementation of the Observer Pattern from the Gang Of Four book, Design Patterns. Observable is a class that implements the GoF's "subject" methods (i.e. addObserver(), removeObserver(), notifyObservers(). Observer is an interface that defines an "update()" method.

The Java Swing GUI uses the Observer Pattern for communication with the widgets, but does not use Java's own Observer Observable classes. Observers are called (event) listeners, and Swing relies on a set of method naming conventions (e.g. addListener()), instead of a common implementation.


See original on c2.com