O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required