List of usage examples for javax.swing JMenuItem isArmed
public boolean isArmed()
From source file:edu.ku.brc.ui.UIHelper.java
/** * Adds a special key listener to process a RETURN key for selecting and item * in the popup list. This is installed only for Windows and Linux. * @param popupMenu the popup menu to be altered. *//*from w w w . jav a 2 s. c o m*/ public static void addSpecialKeyListenerForPopup(final JPopupMenu popupMenu) { if (!UIHelper.isMacOS()) { popupMenu.addKeyListener(new KeyAdapter() { //@Override public void keyPressed(KeyEvent e) { super.keyPressed(e); if (e.getKeyCode() == VK_ENTER) { for (int i = 0; i < popupMenu.getComponentCount(); i++) { Component c = popupMenu.getComponent(i); if (c instanceof JMenuItem) { JMenuItem mi = (JMenuItem) c; if (mi.isArmed()) { mi.doClick(); popupMenu.setVisible(false); } } } } } }); } }