List of usage examples for javax.swing JMenuBar JMenuBar
public JMenuBar()
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create the menu bar JMenuBar menuBar = new JMenuBar(); // Create a menu JMenu menu = new JMenu("Menu Label"); menuBar.add(menu);/*from ww w. jav a2 s.co m*/ // Create a menu item JMenuItem item = new JMenuItem("Item Label"); //item.addActionListener(actionListener); menu.add(item); JFrame frame = new JFrame(); // Install the menu bar in the frame frame.setJMenuBar(menuBar); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Menu Bar Demo"); JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu editMenu = new JMenu("Edit"); JMenu helpMenu = new JMenu("Help"); bar.add(fileMenu);//from w ww . j a v a 2 s . c o m bar.add(editMenu); bar.add(helpMenu); frame.setSize(300, 150); frame.setJMenuBar(bar); frame.setVisible(true); }
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"); fileMenu.setDelay(100);/*from ww w . j a v a 2s. com*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
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"); fileMenu.setMenuLocation(10, 10);/*from w w w. ja va 2s . c o m*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
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 www . j a v a2 s . c o m frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setSelected(true); }
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 www . j a v a 2s . co m frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setPopupMenuVisible(true); }
From source file:AddingRemovingJMenu.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);/*from w w w .jav a 2s. com*/ JMenu editMenu = new JMenu("Edit"); menuBar.add(editMenu); menuBar.remove(0); menuBar.revalidate(); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setAccelerator(KeyStroke.getKeyStroke("F")); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);/*from w ww . j a v a2 s. co m*/ frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:MenuSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Menu Glue Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); bar.add(fileMenu);/*from ww w . j av a2s . c om*/ // Edit Menu, E - Mnemonic JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); bar.add(editMenu); // Move help menu to right side bar.add(Box.createHorizontalGlue()); // Help Menu, H - Mnemonic JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); bar.add(helpMenu); frame.setJMenuBar(bar); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);//from w w w . j a va 2 s. c o m // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); // Separator fileMenu.addSeparator(); // File->Save, S - Mnemonic JMenuItem saveMenuItem = new JMenuItem("Save", KeyEvent.VK_S); fileMenu.add(saveMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }