List of usage examples for javax.swing JMenu setPopupMenuVisible
@BeanProperty(bound = false, expert = true, hidden = true, description = "The popup menu's visibility") public void setPopupMenuVisible(boolean b)
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);//from ww w .java2s . c om frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setPopupMenuVisible(true); }
From source file:org.apache.jmeter.gui.MainFrame.java
/** * Close the currently selected menu.//from ww w.j av a 2 s . c o m */ public void closeMenu() { if (menuBar.isSelected()) { MenuElement[] menuElement = menuBar.getSubElements(); if (menuElement != null) { for (MenuElement element : menuElement) { JMenu menu = (JMenu) element; if (menu.isSelected()) { menu.setPopupMenuVisible(false); menu.setSelected(false); break; } } } } }