HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"The Life Cycle of an Event"
Vol. 1, Issue 2, P.48

	

Listing 1: Event Percolation

public void postEvent(Event e) {
    if (handleEvent(e))
        return;
    Component parent = this.parent;
    if (parent != null) {
        e.translate(x, y);
        if (parent.postEvent(e)) {
          return true;
        }
    }
    if (peer != null) {
        return peer.handleEvent(e);
  }

public boolean handleEvent(Event e) {
   switch (e.id) {
     case Event.MOUSE_ENTER:
       return mouseEnter(e, e.x, e.y);
     case Event.MOUSE_EXIT:
       return mouseExit(e, e.x, e.y);
     case Event.MOUSE_MOVE:
       return mouseMove(e, e.x, e.y);
     case Event.MOUSE_DOWN:
       return mouseDown(e, e.x, e.y);
     case Event.MOUSE_DRAG:
       return mouseDrag(e, e.x, e.y);
     case Event.MOUSE_UP:
       return mouseUp(e, e.x, e.y);
     case Event.KEY_PRESS:
     case Event.KEY_ACTION:
       return keyDown(e, e.key);
     case Event.KEY_RELEASE:
     case Event.KEY_ACTION_RELEASE:
       return keyUp(e, e.key);
     case Event.ACTION_EVENT:
       return action(e, e.arg);
     case Event.GOT_FOCUS:
       return gotFocus(e, e.arg);
     case Event.LOST_FOCUS:
       return lostFocus(e, e.arg);
     }
    return false;
  }


 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: info@sys-con.com

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.