History
Home ] Up ] [ History ] Why a New Event Model? ] Relationship Between Models ] The Java 1.1 Event Model ] AWT Event Hierarchy ] The Event Classes & Interfaces ] Swing Classes & Events ]

 

 

Originally, in JDK 1.0, Java shipped with a simple AWT for portable GUI programming.  It used a model for events based on class inheritance:

  • In order for a program to catch and process GUI events, it must subclass GUI components and override either action() or handleEvent() methods.
  • Returning true from one of these methods consumes the event so it is not processed further.
  • Otherwise the event is propagated sequentially up the GUI hierarchy until:
    • it is consumed, or
    • the root of the hierarchy is reached.
This means that programs have two choices for structuring their event handling code:
  • Each individual component can be subclassed to specifically handle its target events; the result is a plethora of classes.

or:

  • All events for an entire hierarchy (or subset) can be handled by a particular container; the result is that the container's overridden action() or handleEvent() method must contain a complex conditional statement in order to process the events.

Note: If you ever find yourself writing action() or handleEvent() methods in your Java GUI programs, STOP!  You're using the old (prehistoric!) event model.  Instead, learn and use the newer, much superior, event model.

 

This page was last modified on 02 October, 2007