13.13. Handling Events in GUI Controls

In this section we present the general approach for handling events in GUI controls. Depending on the graphical control, different events are generated. For example, a Button generates ActionEvents and a Checkbox generates ItemEvents. As presented in Chapter 11 (Handling Mouse and Keyboard Events), you can use either high-level or low-level event processing to handle events. The two levels of event processing are briefly reviewed below.

  • High-level event processing. Process the event by attaching a listener to the component, using addXxxListener, where Xxx corresponds to the type of event the component can generate. Then, handle the event in the appropriate method defined by the listener. See Section 11.1 ...

Get Core Web Programming, Second 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.