Monitoring State Changes Using Observer/Observable
As you will see in later chapters, Java relies heavily on the Model-View-Controller (MVC) paradigm. MVC stresses that data (a model) should be unaware of how it is used and displayed (by views), and that a third party (a controller) should coordinate their interaction. This chapter serves as a prelude to those concepts by introducing observables and observers.
The Observable Class
The Observable class allows an object to notify other objects when it changes. The concept of observables is borrowed from Smalltalk. In Smalltalk, an object can express interest in another object, meaning that it would like to know when the other object changes.
When building user interfaces, you might have multiple ...