JDK 1.1's version of AWT supports a new delegation model for handling events. The old model dealt with events in a hierarchical fashion. The AWT delivered an event to the target component (e.g., an ACTION_EVENT was delivered to the button that was clicked), which either handled the event or repeatedly passed it up the line to the containing objects. Ultimately, either a containing object handled (i.e., consumed) the event, or the event bubbled out the top of the containment hierarchy.
Programmers working in this model built applets with one of two event-handling architectures. In the first, they subclassed each potential target object (button, checkbox, and so forth) and overr
ode the object's event-catching methods with code that responded appropriately to events. This architecture generated lots of subclasses as objects were individualized to their specific function. In the second architecture, programmers overrode the outermost containing object's
handleEvent
method and dealt with events through an often large and complex
switch
statement.
BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin,
and dozens of other CMP publications—bringing
you critical news and information about wireless communication,
computer security, software development, embedded systems,
and more!