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

Dispatching Events and the AWT Event Queue

There are times when it is desirable to create an event and pass it to a specific component for handling. For instance, some applications may wish to record a sequence of events and play them them back at a later time. Essentially, there are two ways to send an event to a component: invoke Component.dispatchEvent() or use an event queue.

Component.dispatchEvent(AWTEvent) processes the event it is passed in the exact same manner as events that are initiated by user gestures. Figure 9-18 shows an applet that contains two buttons; when the button on the right is activated, mouse pressed and mouse released events are delivered to the button on the left. The mouse events cause the left-hand button to activate ...

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