Comparing the 1.0 and 1.1 Event Models - A Case Study


As we have seen, a great strength of the 1.0 Event model is its simplicity. Again, its weakness might be summarized by the observation that Events frequently involve interactions between Components that are not above or below each other in the Container hierarchy. The following three applets attempt to provide a case study of the issues involved.

The first example simply allows Events to bubble up to the Applet panel where processing takes place. As in the Visual Kiosk example of the previous section, the price that is paid is in the complexity of the Event processing logic. As the Applet panel gets more complex, so the the logic of action().

The second example uses the "Observer" design . Button is subclassed, overriding, action(). The Applet panel is passed to the subclass in its constructor. It is, then, possible to setText() the result TextField in the Button subclass. Note that, as written, there is no interactions between the various Buttons.

The third example uses the new Event model. Notice that the logic of ActionButton and ActionTextField do not need to be altered when, say, one adds more choices. Of course, all "Listener"s must be explicitly "Add"ed.

The fourth example also uses the new Event model.


URL: https://www.umsl.edu/~siegelj/newcourse/part4/ev10_11.htm
Copyright: Jerrold Siegel for The University of Missouri -St. Louis
Last modified on 10/25/2000 21:25:09