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 e)

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 e)
  protected void processFocusEvent(FocusEvent e)
  protected void processKeyEvent(KeyEvent e)
  protected void processMouseEvent(MouseEvent e)
  protected void processMouseMotionEvent(MouseEvent e)
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
Last Modified August 12, 1997
Copyright 1997 Elliotte Rusty Harold
elharo@sunsite.unc.edu