List of usage examples for javax.swing JPopupMenu addMenuKeyListener
public void addMenuKeyListener(MenuKeyListener l)
MenuKeyListener
to the popup menu. From source file:Main.java
/** * Installs the key listener in the tree of components where the argument component is included, starting in the * first parent <i>JFrame</i> or <i>JDialog</i> parent. * //from w w w. j av a 2 s . c o m * @param cmp The starting components in the tree. * @param keyListener The key listener to install. */ public static void installMenuKeyListener(Component cmp, MenuKeyListener keyListener) { List<Component> components = getAllComponents(cmp); for (Component component : components) { if ((component instanceof JPopupMenu)) { JPopupMenu popupMenu = (JPopupMenu) component; popupMenu.addMenuKeyListener(keyListener); } if ((component instanceof JMenuItem)) { JMenuItem menuItem = (JMenuItem) component; menuItem.addMenuKeyListener(keyListener); } } }