if (e instanceof InputEvent)
if (e instanceof WindowEvent) { WindowEvent we = (WindowEvent) e; int id = we.id; int newId = 0;  switch (id) { case WindowEvent.WINDOW_DEICONIFIED: newId = Event.WINDOW_DEICONIFY; break; case WindowEvent.WINDOW_CLOSED: case WindowEvent.WINDOW_CLOSING: newId = Event.WINDOW_DESTROY; break; case WindowEvent.WINDOW_ICONIFIED: newId = Event.WINDOW_ICONIFY; break; case WindowEvent.WINDOW_GAINED_FOCUS: newId = Event.GOT_FOCUS; break; case WindowEvent.WINDOW_LOST_FOCUS: newId = Event.LOST_FOCUS; break; default: return null; }  translated = new Event(target, 0, newId, 0, 0, 0, 0); } else if (e instanceof InputEvent)
  static Event translateEvent (AWTEvent e)  {    Object target = e.getSource ();    Event translated = null;    if (e instanceof InputEvent)      {        InputEvent ie = (InputEvent) e;        long when = ie.getWhen ();        int oldID = 0;        int id = e.getID ();        int oldMods = 0;        int mods = ie.getModifiersEx ();        if ((mods & InputEvent.BUTTON2_DOWN_MASK) != 0)          oldMods |= Event.META_MASK;        else if ((mods & InputEvent.BUTTON3_DOWN_MASK) != 0)          oldMods |= Event.ALT_MASK;        if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0)          oldMods |= Event.SHIFT_MASK;        if ((mods & InputEvent.CTRL_DOWN_MASK) != 0)          oldMods |= Event.CTRL_MASK;        if ((mods & InputEvent.META_DOWN_MASK) != 0)          oldMods |= Event.META_MASK;        if ((mods & InputEvent.ALT_DOWN_MASK) != 0)          oldMods |= Event.ALT_MASK;        if (e instanceof MouseEvent)          {            if (id == MouseEvent.MOUSE_PRESSED)              oldID = Event.MOUSE_DOWN;            else if (id == MouseEvent.MOUSE_RELEASED)              oldID = Event.MOUSE_UP;            else if (id == MouseEvent.MOUSE_MOVED)              oldID = Event.MOUSE_MOVE;            else if (id == MouseEvent.MOUSE_DRAGGED)              oldID = Event.MOUSE_DRAG;            else if (id == MouseEvent.MOUSE_ENTERED)              oldID = Event.MOUSE_ENTER;            else if (id == MouseEvent.MOUSE_EXITED)              oldID = Event.MOUSE_EXIT;            else              // No analogous AWT 1.0 mouse event.              return null;            MouseEvent me = (MouseEvent) e;            translated = new Event (target, when, oldID,                                    me.getX (), me.getY (), 0, oldMods);          }        else if (e instanceof KeyEvent)          {            if (id == KeyEvent.KEY_PRESSED)              oldID = Event.KEY_PRESS;            else if (e.getID () == KeyEvent.KEY_RELEASED)              oldID = Event.KEY_RELEASE;            else              // No analogous AWT 1.0 key event.              return null;            int oldKey = 0;            int newKey = ((KeyEvent) e).getKeyCode ();            switch (newKey)              {              case KeyEvent.VK_BACK_SPACE:                oldKey = Event.BACK_SPACE;                break;              case KeyEvent.VK_CAPS_LOCK:                oldKey = Event.CAPS_LOCK;                break;              case KeyEvent.VK_DELETE:                oldKey = Event.DELETE;                break;              case KeyEvent.VK_DOWN:              case KeyEvent.VK_KP_DOWN:                oldKey = Event.DOWN;                break;              case KeyEvent.VK_END:                oldKey = Event.END;                break;              case KeyEvent.VK_ENTER:                oldKey = Event.ENTER;                break;              case KeyEvent.VK_ESCAPE:                oldKey = Event.ESCAPE;                break;              case KeyEvent.VK_F1:                oldKey = Event.F1;                break;              case KeyEvent.VK_F10:                oldKey = Event.F10;                break;              case KeyEvent.VK_F11:                oldKey = Event.F11;                break;              case KeyEvent.VK_F12:                oldKey = Event.F12;                break;              case KeyEvent.VK_F2:                oldKey = Event.F2;                break;              case KeyEvent.VK_F3:                oldKey = Event.F3;                break;              case KeyEvent.VK_F4:                oldKey = Event.F4;                break;              case KeyEvent.VK_F5:                oldKey = Event.F5;                break;              case KeyEvent.VK_F6:                oldKey = Event.F6;                break;              case KeyEvent.VK_F7:                oldKey = Event.F7;                break;              case KeyEvent.VK_F8:                oldKey = Event.F8;                break;              case KeyEvent.VK_F9:                oldKey = Event.F9;                break;              case KeyEvent.VK_HOME:                oldKey = Event.HOME;                break;              case KeyEvent.VK_INSERT:                oldKey = Event.INSERT;                break;              case KeyEvent.VK_LEFT:              case KeyEvent.VK_KP_LEFT:                oldKey = Event.LEFT;                break;              case KeyEvent.VK_NUM_LOCK:                oldKey = Event.NUM_LOCK;                break;              case KeyEvent.VK_PAUSE:                oldKey = Event.PAUSE;                break;              case KeyEvent.VK_PAGE_DOWN:                oldKey = Event.PGDN;                break;              case KeyEvent.VK_PAGE_UP:                oldKey = Event.PGUP;                break;              case KeyEvent.VK_PRINTSCREEN:                oldKey = Event.PRINT_SCREEN;                break;              case KeyEvent.VK_RIGHT:              case KeyEvent.VK_KP_RIGHT:                oldKey = Event.RIGHT;                break;              case KeyEvent.VK_SCROLL_LOCK:                oldKey = Event.SCROLL_LOCK;                break;              case KeyEvent.VK_TAB:                oldKey = Event.TAB;                break;              case KeyEvent.VK_UP:              case KeyEvent.VK_KP_UP:                oldKey = Event.UP;                break;              default:                oldKey = (int) ((KeyEvent) e).getKeyChar();              }            translated = new Event (target, when, oldID,                                    0, 0, oldKey, oldMods);          }      }    else if (e instanceof AdjustmentEvent)      {	AdjustmentEvent ae = (AdjustmentEvent) e;	int type = ae.getAdjustmentType();	int oldType;	if (type == AdjustmentEvent.BLOCK_DECREMENT)	  oldType = Event.SCROLL_PAGE_UP;	else if (type == AdjustmentEvent.BLOCK_INCREMENT)	  oldType = Event.SCROLL_PAGE_DOWN;	else if (type == AdjustmentEvent.TRACK)	  oldType = Event.SCROLL_ABSOLUTE;	else if (type == AdjustmentEvent.UNIT_DECREMENT)	  oldType = Event.SCROLL_LINE_UP;	else if (type == AdjustmentEvent.UNIT_INCREMENT)	  oldType = Event.SCROLL_LINE_DOWN;	else	  oldType = type;	translated = new Event(target, oldType, new Integer(ae.getValue()));      }    else if (e instanceof ActionEvent)      translated = new Event (target, Event.ACTION_EVENT,                              ((ActionEvent) e).getActionCommand ());    return translated;  }