787: Highlights
- If you want to build a GUI, then adopt the modelview approach.
- If you want your program to react to model changes, then
- Arrange for the model class to extend the
Observable
class.
- Insert calls to
setChanged
and notifyObservers
in the
setters of the model.
- Define an observer class that implements the
Observer
interface.
- Define an
update
method in the observer class such that
update
fetches information from the model and relays that
information to a view.
- Connect an observer to the model using
addObserver
.
If you want your program to react to view events, then
Define a listener class that implements an appropriate listener interface.
Define listener methods as dictated by the listener interface such that
those methods fetch information from the view and relay that information
to a model.
Connect the listener to the appropriate component.