Ejemplo n.º 1
0
 public void keyReleased(KeyEvent e) {
   int code = e.getKeyCode();
   if (code > 0 && code < keys.length) {
     keys[code] = false;
   }
   if (externalListener != null) {
     externalListener.keyReleased(e);
   }
 }
Ejemplo n.º 2
0
 private void fireKeyEvent(KeyEvent e) {
   for (KeyListener l : mKeyListeners) {
     if (e.getID() == KeyEvent.KEY_PRESSED) {
       l.keyPressed(e);
     } else if (e.getID() == KeyEvent.KEY_RELEASED) {
       l.keyReleased(e);
     } else if (e.getID() == KeyEvent.KEY_TYPED) {
       l.keyTyped(e);
     }
   }
 }
Ejemplo n.º 3
0
 void notifyKeyEvent(final KeyEvent e) {
   for (KeyListener l : myKeyListeners) {
     if (e.getID() == KeyEvent.KEY_PRESSED) {
       l.keyPressed(e);
     } else if (e.getID() == KeyEvent.KEY_RELEASED) {
       l.keyReleased(e);
     } else if (e.getID() == KeyEvent.KEY_TYPED) {
       l.keyTyped(e);
     }
   }
 }
Ejemplo n.º 4
0
 protected void processKeyEvent(KeyEvent e) {
   if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     EventListener[] el = super.getListeners(KeyListener.class);
     if (e.getID() != KeyEvent.KEY_RELEASED) return;
     for (int i = 0; i < el.length; i++) {
       KeyListener kl = (KeyListener) el[i];
       kl.keyReleased(e);
     }
     return;
   }
   super.processKeyEvent(e);
 }
Ejemplo n.º 5
0
  private static void dispatchEvent(int eventCode, Key key, int keyCode, Component component) {
    int modifier = key.getModifier().getCode();
    KeyEvent event = new KeyEvent(component, eventCode, 0, modifier, keyCode, key.getChar());

    for (KeyListener listener : component.getKeyListeners()) {
      switch (eventCode) {
        case KEY_PRESSED:
          listener.keyPressed(event);
          break;
        case KEY_TYPED:
          listener.keyTyped(event);
          break;
        case KEY_RELEASED:
          listener.keyReleased(event);
          break;
      }
    }
    SwingUtilities.processKeyBindings(event);
  }
 /**
  * Handles the keyReleased event by invoking the keyReleased methods on listener-a and listener-b.
  *
  * @param e the key event
  */
 public void keyReleased(KeyEvent e) {
   ((KeyListener) a).keyReleased(e);
   ((KeyListener) b).keyReleased(e);
 }