Processing Events

The Java runtime is responsible for handling the event queue. In particular it makes sure that each low-level event is directed to the proper component. You do not need to worry about deciding which component the event is meant for. The runtime handles this for you. In particular the runtime passes the event to the component's processEvent() method:

protected void processEvent(AWTEvent evt)

The processEvent() method determines the type of the event and passes it on to one of five other methods in the java.awt.Component class:

  protected void processComponentEvent(ComponentEvent evt)
  protected void processFocusEvent(FocusEvent evt)
  protected void processKeyEvent(KeyEvent evt)
  protected void processMouseEvent(MouseEvent evt)
  protected void processMouseMotionEvent(MouseEvent evt)

Each of these methods looks to see if any listener objects of the right type are registered for this component. If so, the event is passed to each of those listener objects in an unpredictable order.

Internally, these methods use a java.awt.AWTEventMulticaster object to track the registration of listeners with a component.


Previous | Next | Top | Cafe au Lait

Copyright 1997, 2006 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified April 26, 2006