Example #1
0
  /**
   * Processes a key event forwarded from the <code>MenuSelectionManager</code> and changes the menu
   * selection, if necessary, by using <code>MenuSelectionManager</code>'s API.
   *
   * <p>Note: you do not have to forward the event to sub-components. This is done automatically by
   * the <code>MenuSelectionManager</code>.
   *
   * @param e a <code>KeyEvent</code>
   * @param path the <code>MenuElement</code> path array
   * @param manager the <code>MenuSelectionManager</code>
   */
  public void processKeyEvent(KeyEvent e, MenuElement path[], MenuSelectionManager manager) {
    MenuKeyEvent mke =
        new MenuKeyEvent(
            e.getComponent(),
            e.getID(),
            e.getWhen(),
            e.getModifiers(),
            e.getKeyCode(),
            e.getKeyChar(),
            path,
            manager);
    processMenuKeyEvent(mke);

    if (mke.isConsumed()) {
      e.consume();
    }
  }
Example #2
0
 /**
  * Handles a keystroke in a menu.
  *
  * @param e a <code>MenuKeyEvent</code> object
  * @since 1.5
  */
 private void processMenuKeyEvent(MenuKeyEvent e) {
   switch (e.getID()) {
     case KeyEvent.KEY_PRESSED:
       fireMenuKeyPressed(e);
       break;
     case KeyEvent.KEY_RELEASED:
       fireMenuKeyReleased(e);
       break;
     case KeyEvent.KEY_TYPED:
       fireMenuKeyTyped(e);
       break;
     default:
       break;
   }
 }