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

The Delegation Event Model

The delegation event model derives its name from the fact that event handling is delegated from an event source to one or more event listeners.

The premise behind the delegation event model is simple: components fire events, which can be listened for and acted upon by listeners. Listeners are registered with a component by invoking one of a number of addXYZListener(XYZListener) methods. After a listener is added to a component, appropriate methods in the listener's interface will be called when the corresponding type of event is fired by the component.

Components, Events and Listeners

The applet listed shown in Figure 9-1 and listed in Example 9-1 illustrates the fundamental concepts of the delegation event model.

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