Java 类javax.swing.event.MenuKeyEvent 实例源码

项目:javify    文件:JMenuItem.java   
/**
 * This method fires MenuKeyEvent to registered listeners.
 * Different types of MenuKeyEvents are fired depending
 * on the observed key event.
 *
 * @param event DOCUMENT ME!
 */
public void processMenuKeyEvent(MenuKeyEvent event)
{
  switch (event.getID())
  {
    case KeyEvent.KEY_PRESSED:
      fireMenuKeyPressed(event);
      break;
    case KeyEvent.KEY_RELEASED:
      fireMenuKeyReleased(event);
      break;
    case KeyEvent.KEY_TYPED:
      fireMenuKeyTyped(event);
      break;
    default:
      break;
  }
}
项目:jvm-stm    文件:JMenuItem.java   
/**
 * This method fires MenuKeyEvent to registered listeners.
 * Different types of MenuKeyEvents are fired depending
 * on the observed key event.
 *
 * @param event DOCUMENT ME!
 */
public void processMenuKeyEvent(MenuKeyEvent event)
{
  switch (event.getID())
  {
    case KeyEvent.KEY_PRESSED:
      fireMenuKeyPressed(event);
      break;
    case KeyEvent.KEY_RELEASED:
      fireMenuKeyReleased(event);
      break;
    case KeyEvent.KEY_TYPED:
      fireMenuKeyTyped(event);
      break;
    default:
      break;
  }
}
项目:cn1    文件:JMenuItem.java   
public void processKeyEvent(final KeyEvent event, final MenuElement[] path,
                            final MenuSelectionManager manager) {
    final MenuKeyEvent menuKeyEvent = new MenuKeyEvent(event.getComponent(), event.getID(),
                                         event.getWhen(), event.getModifiersEx(),
                                         event.getKeyCode(), event.getKeyChar(),
                                         path, manager);
    processMenuKeyEvent(menuKeyEvent);
    if (menuKeyEvent.isConsumed()) {
        event.consume();
        return;
    }
    if (processMnemonics(event)) {
        event.consume();
        return;
    }
}
项目:cn1    文件:JMenuItemTest.java   
public void testFireMenuKeyReleased() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyReleased(event1);
    assertEquals("event fired properly ", "released", listener1.event);
    assertEquals("event fired properly ", "released", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
    menuItem.fireMenuKeyReleased(event1);
    assertEquals("event fired properly ", "released", listener1.event);
    assertEquals("event fired properly ", "released", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
}
项目:cn1    文件:JMenuItemTest.java   
public void testFireMenuKeyTyped() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyTyped(event1);
    assertEquals("event fired properly ", "typed", listener1.event);
    assertEquals("event fired properly ", "typed", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
    menuItem.fireMenuKeyTyped(event1);
    assertEquals("event fired properly ", "typed", listener1.event);
    assertEquals("event fired properly ", "typed", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
}
项目:cn1    文件:JMenuItemTest.java   
public void testProcessMenuKeyEvent() {
    final MenuSelectionManager menuSelectionManager = new MenuSelectionManager();
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, KeyEvent.KEY_PRESSED, 0, 0, 0, 'a',
            new MenuElement[0], menuSelectionManager);
    MenuKeyEvent event2 = new MenuKeyEvent(menuItem, KeyEvent.KEY_RELEASED, 0, 0, 0, 'b',
            new MenuElement[0], menuSelectionManager);
    MenuKeyEvent event3 = new MenuKeyEvent(menuItem, KeyEvent.KEY_TYPED, 0, 0, 0, 'c',
            new MenuElement[0], menuSelectionManager);
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.processMenuKeyEvent(event1);
    assertEquals("event fired properly ", "pressed", listener1.event);
    menuItem.processMenuKeyEvent(event2);
    assertEquals("event fired properly ", "released", listener1.event);
    menuItem.processMenuKeyEvent(event3);
    assertEquals("event fired properly ", "typed", listener1.event);
}
项目:JamVM-PH    文件:JMenuItem.java   
/**
 * This method fires MenuKeyEvent to registered listeners.
 * Different types of MenuKeyEvents are fired depending
 * on the observed key event.
 *
 * @param event DOCUMENT ME!
 */
public void processMenuKeyEvent(MenuKeyEvent event)
{
  switch (event.getID())
  {
    case KeyEvent.KEY_PRESSED:
      fireMenuKeyPressed(event);
      break;
    case KeyEvent.KEY_RELEASED:
      fireMenuKeyReleased(event);
      break;
    case KeyEvent.KEY_TYPED:
      fireMenuKeyTyped(event);
      break;
    default:
      break;
  }
}
项目:classpath    文件:JMenuItem.java   
/**
 * This method fires MenuKeyEvent to registered listeners.
 * Different types of MenuKeyEvents are fired depending
 * on the observed key event.
 *
 * @param event DOCUMENT ME!
 */
public void processMenuKeyEvent(MenuKeyEvent event)
{
  switch (event.getID())
  {
    case KeyEvent.KEY_PRESSED:
      fireMenuKeyPressed(event);
      break;
    case KeyEvent.KEY_RELEASED:
      fireMenuKeyReleased(event);
      break;
    case KeyEvent.KEY_TYPED:
      fireMenuKeyTyped(event);
      break;
    default:
      break;
  }
}
项目:freeVM    文件:JMenuItem.java   
public void processKeyEvent(final KeyEvent event, final MenuElement[] path,
                            final MenuSelectionManager manager) {
    final MenuKeyEvent menuKeyEvent = new MenuKeyEvent(event.getComponent(), event.getID(),
                                         event.getWhen(), event.getModifiersEx(),
                                         event.getKeyCode(), event.getKeyChar(),
                                         path, manager);
    processMenuKeyEvent(menuKeyEvent);
    if (menuKeyEvent.isConsumed()) {
        event.consume();
        return;
    }
    if (processMnemonics(event)) {
        event.consume();
        return;
    }
}
项目:freeVM    文件:JMenuItemTest.java   
public void testFireMenuKeyReleased() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyReleased(event1);
    assertEquals("event fired properly ", "released", listener1.event);
    assertEquals("event fired properly ", "released", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
    menuItem.fireMenuKeyReleased(event1);
    assertEquals("event fired properly ", "released", listener1.event);
    assertEquals("event fired properly ", "released", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
}
项目:freeVM    文件:JMenuItemTest.java   
public void testFireMenuKeyTyped() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyTyped(event1);
    assertEquals("event fired properly ", "typed", listener1.event);
    assertEquals("event fired properly ", "typed", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
    menuItem.fireMenuKeyTyped(event1);
    assertEquals("event fired properly ", "typed", listener1.event);
    assertEquals("event fired properly ", "typed", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
}
项目:freeVM    文件:JMenuItemTest.java   
public void testProcessMenuKeyEvent() {
    final MenuSelectionManager menuSelectionManager = new MenuSelectionManager();
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, KeyEvent.KEY_PRESSED, 0, 0, 0, 'a',
            new MenuElement[0], menuSelectionManager);
    MenuKeyEvent event2 = new MenuKeyEvent(menuItem, KeyEvent.KEY_RELEASED, 0, 0, 0, 'b',
            new MenuElement[0], menuSelectionManager);
    MenuKeyEvent event3 = new MenuKeyEvent(menuItem, KeyEvent.KEY_TYPED, 0, 0, 0, 'c',
            new MenuElement[0], menuSelectionManager);
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.processMenuKeyEvent(event1);
    assertEquals("event fired properly ", "pressed", listener1.event);
    menuItem.processMenuKeyEvent(event2);
    assertEquals("event fired properly ", "released", listener1.event);
    menuItem.processMenuKeyEvent(event3);
    assertEquals("event fired properly ", "typed", listener1.event);
}
项目:freeVM    文件:JMenuItem.java   
public void processKeyEvent(final KeyEvent event, final MenuElement[] path,
                            final MenuSelectionManager manager) {
    final MenuKeyEvent menuKeyEvent = new MenuKeyEvent(event.getComponent(), event.getID(),
                                         event.getWhen(), event.getModifiersEx(),
                                         event.getKeyCode(), event.getKeyChar(),
                                         path, manager);
    processMenuKeyEvent(menuKeyEvent);
    if (menuKeyEvent.isConsumed()) {
        event.consume();
        return;
    }
    if (processMnemonics(event)) {
        event.consume();
        return;
    }
}
项目:freeVM    文件:JMenuItemTest.java   
public void testFireMenuKeyReleased() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyReleased(event1);
    assertEquals("event fired properly ", "released", listener1.event);
    assertEquals("event fired properly ", "released", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
    menuItem.fireMenuKeyReleased(event1);
    assertEquals("event fired properly ", "released", listener1.event);
    assertEquals("event fired properly ", "released", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
}
项目:freeVM    文件:JMenuItemTest.java   
public void testFireMenuKeyTyped() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyTyped(event1);
    assertEquals("event fired properly ", "typed", listener1.event);
    assertEquals("event fired properly ", "typed", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
    menuItem.fireMenuKeyTyped(event1);
    assertEquals("event fired properly ", "typed", listener1.event);
    assertEquals("event fired properly ", "typed", listener2.event);
    assertSame("one event fired ", listener1.event, listener2.event);
}
项目:freeVM    文件:JMenuItemTest.java   
public void testProcessMenuKeyEvent() {
    final MenuSelectionManager menuSelectionManager = new MenuSelectionManager();
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, KeyEvent.KEY_PRESSED, 0, 0, 0, 'a',
            new MenuElement[0], menuSelectionManager);
    MenuKeyEvent event2 = new MenuKeyEvent(menuItem, KeyEvent.KEY_RELEASED, 0, 0, 0, 'b',
            new MenuElement[0], menuSelectionManager);
    MenuKeyEvent event3 = new MenuKeyEvent(menuItem, KeyEvent.KEY_TYPED, 0, 0, 0, 'c',
            new MenuElement[0], menuSelectionManager);
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.processMenuKeyEvent(event1);
    assertEquals("event fired properly ", "pressed", listener1.event);
    menuItem.processMenuKeyEvent(event2);
    assertEquals("event fired properly ", "released", listener1.event);
    menuItem.processMenuKeyEvent(event3);
    assertEquals("event fired properly ", "typed", listener1.event);
}
项目:freecol    文件:FreeColAction.java   
@Override
public void menuKeyPressed(MenuKeyEvent e) {

    if (e.getKeyCode() == mnemonic) {
        ActionEvent ae = new ActionEvent(e.getSource(), e.getID(), (String) getValue(Action.NAME),
                                         e.getModifiers());
        actionPerformed(ae);

        e.consume();
    }
}
项目:JuggleMasterPro    文件:PatternsFileJCheckBoxMenuItem.java   
@Override final public void menuKeyPressed(MenuKeyEvent objPmenuKeyEvent) {
    int intLkeysModifiers = objPmenuKeyEvent.getModifiers();
    final int intLaltMask = InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK | InputEvent.ALT_GRAPH_DOWN_MASK;
    if (Tools.intersects(intLkeysModifiers, intLaltMask)) {
        // Tools.debug("Yep !");
        intLkeysModifiers ^= intLaltMask;
        PatternsFileJCheckBoxMenuItem.setKeysModifiers(intLkeysModifiers);
        return;
    }
    PatternsFileJCheckBoxMenuItem.setKeysModifiers(objPmenuKeyEvent.getModifiers());
}
项目:JuggleMasterPro    文件:PatternsFileJCheckBoxMenuItem.java   
@Override final public void menuKeyReleased(MenuKeyEvent objPmenuKeyEvent) {
    int intLkeysModifiers = objPmenuKeyEvent.getModifiers();
    final int intLaltMask = InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK | InputEvent.ALT_GRAPH_DOWN_MASK;
    if (Tools.intersects(intLkeysModifiers, intLaltMask)) {
        Tools.debug("Yep !");
        intLkeysModifiers ^= intLaltMask;
        PatternsFileJCheckBoxMenuItem.setKeysModifiers(intLkeysModifiers);
        return;
    }
    PatternsFileJCheckBoxMenuItem.setKeysModifiers(objPmenuKeyEvent.getModifiers());
}
项目:openjdk-jdk10    文件:JMenuItemOperator.java   
/**
 * Maps {@code JMenuItem.processMenuKeyEvent(MenuKeyEvent)} through queue
 */
public void processMenuKeyEvent(final MenuKeyEvent menuKeyEvent) {
    runMapping(new MapVoidAction("processMenuKeyEvent") {
        @Override
        public void map() {
            ((JMenuItem) getSource()).processMenuKeyEvent(menuKeyEvent);
        }
    });
}
项目:FreeCol    文件:FreeColAction.java   
@Override
public void menuKeyPressed(MenuKeyEvent e) {

    if (e.getKeyCode() == mnemonic) {
        ActionEvent ae = new ActionEvent(e.getSource(), e.getID(), (String) getValue(Action.NAME),
                                         e.getModifiers());
        actionPerformed(ae);

        e.consume();
    }
}
项目:openjdk9    文件:JMenuItemOperator.java   
/**
 * Maps {@code JMenuItem.processMenuKeyEvent(MenuKeyEvent)} through queue
 */
public void processMenuKeyEvent(final MenuKeyEvent menuKeyEvent) {
    runMapping(new MapVoidAction("processMenuKeyEvent") {
        @Override
        public void map() {
            ((JMenuItem) getSource()).processMenuKeyEvent(menuKeyEvent);
        }
    });
}
项目:j2se_for_android    文件:JPopupMenu.java   
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();
    }
}
项目:j2se_for_android    文件:JPopupMenu.java   
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;
    }
}
项目:j2se_for_android    文件:JPopupMenu.java   
private void fireMenuKeyPressed(MenuKeyEvent event) {
    Object[] listeners = list.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == MenuKeyListener.class) {
            ((MenuKeyListener) listeners[i + 1]).menuKeyPressed(event);
        }
    }
}
项目:j2se_for_android    文件:JPopupMenu.java   
private void fireMenuKeyReleased(MenuKeyEvent event) {
    Object[] listeners = list.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == MenuKeyListener.class) {
            ((MenuKeyListener) listeners[i + 1]).menuKeyReleased(event);
        }
    }
}
项目:j2se_for_android    文件:JPopupMenu.java   
private void fireMenuKeyTyped(MenuKeyEvent event) {
    Object[] listeners = list.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == MenuKeyListener.class) {
            ((MenuKeyListener) listeners[i + 1]).menuKeyTyped(event);
        }
    }
}
项目:javify    文件:JMenuItem.java   
/**
 * Process key events forwarded from MenuSelectionManager.
 *
 * @param event event forwarded from MenuSelectionManager
 * @param path path to the menu element from which event was generated
 * @param manager MenuSelectionManager for the current menu hierarchy
 */
public void processKeyEvent(KeyEvent event, MenuElement[] path,
                            MenuSelectionManager manager)
{
  MenuKeyEvent e = new MenuKeyEvent(event.getComponent(), event.getID(),
                                    event.getWhen(), event.getModifiers(),
                                    event.getKeyCode(), event.getKeyChar(),
                                    path, manager);
  processMenuKeyEvent(e);

  // Consume original key event, if the menu key event has been consumed.
  if (e.isConsumed())
    event.consume();
}
项目:javify    文件:JMenuItem.java   
/**
 * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
 *
 * @param event The event signifying that key associated with this menu was pressed
 */
protected void fireMenuKeyPressed(MenuKeyEvent event)
{
  EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);

  for (int i = 0; i < ll.length; i++)
    ((MenuKeyListener) ll[i]).menuKeyPressed(event);
}
项目:javify    文件:JMenuItem.java   
/**
 * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
 *
 * @param event The event signifying that key associated with this menu was released
 */
protected void fireMenuKeyReleased(MenuKeyEvent event)
{
  EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);

  for (int i = 0; i < ll.length; i++)
    ((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
项目:javify    文件:JMenuItem.java   
/**
 * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
 *
 * @param event The event signifying that key associated with this menu was typed.
 *        The key is typed when it was pressed and then released
 */
protected void fireMenuKeyTyped(MenuKeyEvent event)
{
  EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);

  for (int i = 0; i < ll.length; i++)
    ((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
项目:jvm-stm    文件:JMenuItem.java   
/**
 * Process key events forwarded from MenuSelectionManager.
 *
 * @param event event forwarded from MenuSelectionManager
 * @param path path to the menu element from which event was generated
 * @param manager MenuSelectionManager for the current menu hierarchy
 */
public void processKeyEvent(KeyEvent event, MenuElement[] path,
                            MenuSelectionManager manager)
{
  MenuKeyEvent e = new MenuKeyEvent(event.getComponent(), event.getID(),
                                    event.getWhen(), event.getModifiers(),
                                    event.getKeyCode(), event.getKeyChar(),
                                    path, manager);
  processMenuKeyEvent(e);

  // Consume original key event, if the menu key event has been consumed.
  if (e.isConsumed())
    event.consume();
}
项目:jvm-stm    文件:JMenuItem.java   
/**
 * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
 *
 * @param event The event signifying that key associated with this menu was pressed
 */
protected void fireMenuKeyPressed(MenuKeyEvent event)
{
  EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);

  for (int i = 0; i < ll.length; i++)
    ((MenuKeyListener) ll[i]).menuKeyPressed(event);
}
项目:jvm-stm    文件:JMenuItem.java   
/**
 * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
 *
 * @param event The event signifying that key associated with this menu was released
 */
protected void fireMenuKeyReleased(MenuKeyEvent event)
{
  EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);

  for (int i = 0; i < ll.length; i++)
    ((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
项目:jvm-stm    文件:JMenuItem.java   
/**
 * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
 *
 * @param event The event signifying that key associated with this menu was typed.
 *        The key is typed when it was pressed and then released
 */
protected void fireMenuKeyTyped(MenuKeyEvent event)
{
  EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);

  for (int i = 0; i < ll.length; i++)
    ((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
项目:stendhal    文件:WtPopupMenu.java   
@Override
public void processMenuKeyEvent(final MenuKeyEvent ev) {
    switch (ev.getKeyCode()) {
    case KeyEvent.VK_ESCAPE:
        break;

    default:
        redirectEvent(ev);
    }

    if (!ev.isConsumed()) {
        super.processMenuKeyEvent(ev);
    }
}
项目:opendocs    文件:WorkingSetMenu.java   
@Override
public void menuKeyPressed(MenuKeyEvent e) {
    if (e.isControlDown() && isHovered) {
        if (ctrlLabel != null) {
            setIcon(ctrlLabel.getIcon());
            setText(ctrlLabel.getText());
        }
    } else if (e.isShiftDown() && isHovered) {
        if (shiftLabel != null) {
            setIcon(shiftLabel.getIcon());
            setText(shiftLabel.getText());
        }
    }
    repaint();
}
项目:cn1    文件:JMenuItem.java   
public void processMenuKeyEvent(final MenuKeyEvent e) {
    if (e.getID() == KeyEvent.KEY_PRESSED) {
        fireMenuKeyPressed(e);
    } else if (e.getID() == KeyEvent.KEY_RELEASED) {
        fireMenuKeyReleased(e);
    } else if (e.getID() == KeyEvent.KEY_TYPED) {
        fireMenuKeyTyped(e);
    }
}
项目:cn1    文件:JMenuItemTest.java   
public void testFireMenuKeyPressed() {
    MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0],
            new MenuSelectionManager());
    ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener();
    ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener();
    menuItem.addMenuKeyListener(listener1);
    menuItem.addMenuKeyListener(listener2);
    menuItem.fireMenuKeyPressed(event1);
    assertEquals("event fired properly ", "pressed", listener1.event);
    assertEquals("event fired properly ", "pressed", listener2.event);
    menuItem.fireMenuKeyPressed(event1);
    assertEquals("event fired properly ", "pressed", listener1.event);
    assertEquals("event fired properly ", "pressed", listener2.event);
}
项目:JamVM-PH    文件:JMenuItem.java   
/**
 * Process key events forwarded from MenuSelectionManager.
 *
 * @param event event forwarded from MenuSelectionManager
 * @param path path to the menu element from which event was generated
 * @param manager MenuSelectionManager for the current menu hierarchy
 */
public void processKeyEvent(KeyEvent event, MenuElement[] path,
                            MenuSelectionManager manager)
{
  MenuKeyEvent e = new MenuKeyEvent(event.getComponent(), event.getID(),
                                    event.getWhen(), event.getModifiers(),
                                    event.getKeyCode(), event.getKeyChar(),
                                    path, manager);
  processMenuKeyEvent(e);

  // Consume original key event, if the menu key event has been consumed.
  if (e.isConsumed())
    event.consume();
}