Shortcomings of the Inheritance-Based Event Model

The original event model discussed in this chapter was appropriate for small applets with simple event handling needs, but the model did not scale well for a number of reasons, a few of which we will take the time to briefly explore. The new event model, covered in the next chapter, is delegation-based as opposed to the old model, which was inheritance-based. The inheritance-based model required a component to be extended in order to handle events. Example 8-5 is a simple example of the original event handling mechanism in action; MouseCanvas extends Canvas and overrides handleEvent() to process mouse down events, and mouseUp() to process mouse up events.

Example 8-5. CanvasEventExample—An Example ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.