List of usage examples for javax.swing JMenu setSelected
@BeanProperty(expert = true, hidden = true, description = "When the menu is selected, its popup child is shown.") public void setSelected(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 w w w . j a v a2 s. c om frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setSelected(true); }
From source file:org.apache.jmeter.gui.MainFrame.java
/** * Close the currently selected menu.//from w w w . j ava2 s .co 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; } } } } }