The Java 1.1 Event Model
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 ]

 

 

The Java 1.1 event model is a Delegation Event Model

It is used by both the GUI and by Java Beans (and virtually everything else that is coming out in the Java world!)

Events are no longer represented by a single event class (like java.awt.Event) with numeric ids.

Instead, events are represented by a hiearchy of event classes:

  • ActionEvent, WindowEvent, MouseEvent, KeyEvent, etc.
Since a single event class may be used to represent more than one event type (e.g. MouseEvent represents mouse up, mouse down, mouse drag, mouse move, etc.), some event classes may also contain an id (unique within that class) which maps it to its specific event types.

Every event is a subclass of java.util.EventObject

GUI Events are subclasses of java.awt.AWTEvent (which itself is a subclass of EventObject)

If a class is interested in an event, it declares itself to be a listener for that particular class of event.

When an Event Occurs

  • When a object that generates an event needs to tell a listener object that an event happened, the system:
    • Calls the appropriate method of the listener interface
    • Passes to that method an object of the appropriate type the extends from EventObject
 

This page was last modified on 02 October, 2007