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

Event Handling Design

Although the new event model is much improved over the old model, you may find yourself pining for the simplicity of the old model where you essentially had only one choice for handling events, namely, extending a component and embedding event handling code in the extension.[19] The new model, coupled with inner classes, allows for much more flexibility than the old event model. For instance, when handling events with the delegation-based event model you can:

[19] Actually, you could manually delegate event handling to another object, but it's a lot of work and is quite error-prone.

  • Use the old event model

  • Use the inheritance-based mechanism provided with the new model

  • Have components listen to themselves

  • Encapsulate the event ...

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