public void testAddGetRemoveMenuKeyListener() { MenuKeyListener listener1 = new ConcreteMenuKeyListener(); MenuKeyListener listener2 = new ConcreteMenuKeyListener(); MenuKeyListener listener3 = new ConcreteMenuKeyListener(); EventListener[] listenersArray = null; listenersArray = menuItem.getMenuKeyListeners(); int initialValue = listenersArray.length; menuItem.addMenuKeyListener(listener1); menuItem.addMenuKeyListener(listener2); menuItem.addMenuKeyListener(listener2); listenersArray = menuItem.getMenuKeyListeners(); assertEquals(initialValue + 3, listenersArray.length); menuItem.removeMenuKeyListener(listener1); menuItem.addMenuKeyListener(listener3); menuItem.addMenuKeyListener(listener3); listenersArray = menuItem.getMenuKeyListeners(); assertEquals(initialValue + 4, listenersArray.length); menuItem.removeMenuKeyListener(listener3); menuItem.removeMenuKeyListener(listener3); listenersArray = menuItem.getMenuKeyListeners(); assertEquals(initialValue + 2, listenersArray.length); menuItem.removeMenuKeyListener(listener2); menuItem.removeMenuKeyListener(listener2); listenersArray = menuItem.getMenuKeyListeners(); assertEquals(initialValue, listenersArray.length); }
/** * Maps {@code JMenuItem.addMenuKeyListener(MenuKeyListener)} through queue */ public void addMenuKeyListener(final MenuKeyListener menuKeyListener) { runMapping(new MapVoidAction("addMenuKeyListener") { @Override public void map() { ((JMenuItem) getSource()).addMenuKeyListener(menuKeyListener); } }); }
/** * Maps {@code JMenuItem.removeMenuKeyListener(MenuKeyListener)} * through queue */ public void removeMenuKeyListener(final MenuKeyListener menuKeyListener) { runMapping(new MapVoidAction("removeMenuKeyListener") { @Override public void map() { ((JMenuItem) getSource()).removeMenuKeyListener(menuKeyListener); } }); }
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); } } }
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); } } }
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); } } }
/** * 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); }
/** * 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); }
/** * 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); }
public MenuKeyListener getMenuKeyListener() { return new InnerMenuKeyListener(); }
public void addMenuKeyListener(MenuKeyListener l) { }
public void removeMenuKeyListener(MenuKeyListener l) { }
public MenuKeyListener[] getMenuKeyListeners() { return list.getListeners(MenuKeyListener.class); }
public void addMenuKeyListener(MenuKeyListener l) { list.add(MenuKeyListener.class, l); }
public void removeMenuKeyListener(MenuKeyListener l) { list.remove(MenuKeyListener.class, l); }
public Popup() { for (MenuKeyListener l : getMenuKeyListeners()) { removeMenuKeyListener(l); } }
protected void fireMenuKeyPressed(final MenuKeyEvent event) { final MenuKeyListener[] listeners = getMenuKeyListeners(); for (int i = 0; i < listeners.length; i++) { listeners[i].menuKeyPressed(event); } }
protected void fireMenuKeyReleased(final MenuKeyEvent event) { final MenuKeyListener[] listeners = getMenuKeyListeners(); for (int i = 0; i < listeners.length; i++) { listeners[i].menuKeyReleased(event); } }
protected void fireMenuKeyTyped(final MenuKeyEvent event) { final MenuKeyListener[] listeners = getMenuKeyListeners(); for (int i = 0; i < listeners.length; i++) { listeners[i].menuKeyTyped(event); } }
public void addMenuKeyListener(final MenuKeyListener listener) { listenerList.add(MenuKeyListener.class, listener); }
public void removeMenuKeyListener(final MenuKeyListener listener) { listenerList.remove(MenuKeyListener.class, listener); }
public MenuKeyListener[] getMenuKeyListeners() { return (MenuKeyListener[])getListeners(MenuKeyListener.class); }
protected MenuKeyListener createMenuKeyListener(final JComponent c) { return null; }
protected MenuKeyListener createMenuKeyListener(JComponent c){ if (Patches.SUN_BUG_ID_4738042) { return new SUN_BUG_ID_4738042_Patch(); } return super.createMenuKeyListener(c); }