List of usage examples for javax.swing JFrame setJMenuBar
@BeanProperty(bound = false, hidden = true, description = "The menubar for accessing pulldown menus from this frame.") public void setJMenuBar(final JMenuBar menubar)
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JRadioButtonMenuItem Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); bar.addNotify();/*from www . j ava 2 s . c om*/ JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("B"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("C"); group.add(menuItem); menu.add(menuItem); bar.add(menu); Component com = bar.getComponent(); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JRadioButtonMenuItem Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); bar.addNotify();//from ww w . j av a 2 s. c o m JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("B"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("C"); group.add(menuItem); menu.add(menuItem); bar.add(menu); bar.setMargin(new Insets(3, 3, 3, 3)); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JRadioButtonMenuItem Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); bar.addNotify();//from ww w .ja v a 2s .c o m JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("B"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("C"); group.add(menuItem); menu.add(menuItem); bar.add(menu); int index = bar.getComponentIndex(menu); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JRadioButtonMenuItem Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); bar.addNotify();/*from www . j a v a 2 s . c om*/ JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("B"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("C"); group.add(menuItem); menu.add(menuItem); bar.add(menu); MenuElement[] elements = bar.getSubElements(); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JRadioButtonMenuItem Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); bar.addNotify();// w w w .j av a 2 s. c om JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("B"); group.add(menuItem); menu.add(menuItem); menuItem = new JRadioButtonMenuItem("C"); group.add(menuItem); menu.add(menuItem); bar.add(menu); SingleSelectionModel model = bar.getSelectionModel(); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:JMenuItemDisabled.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);/*w w w . ja va 2 s .co m*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled JMenuItem pasteMenuItem = new JMenuItem("Paste", KeyEvent.VK_P); KeyStroke ctrlVKeyStroke = KeyStroke.getKeyStroke("control V"); pasteMenuItem.setAccelerator(ctrlVKeyStroke); pasteMenuItem.setEnabled(false); fileMenu.add(pasteMenuItem); 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.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);/*from w w w .jav a 2 s . co m*/ fileMenu.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("File Menu Changed"); } }); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); newMenuItem.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("new menu item changed"); } }); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:edu.ku.brc.specify.toycode.UpdatesApp.java
/** * @param args/*from w ww.j a va2 s .co m*/ */ public static void main(String[] args) { if (args.length == 9) { for (int i = 0; i < args.length; i++) { System.out.println(i + "=" + args[i]); } doingCmdLine = true; UpdatesApp updateApp = new UpdatesApp(); try { updateApp.merge(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); } catch (java.lang.NullPointerException ex) { System.err.println("****The merge process failed: check for errors above."); } } else { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIHelper.OSTYPE osType = UIHelper.getOSType(); if (osType == UIHelper.OSTYPE.Windows) { //UIManager.setLookAndFeel(new WindowsLookAndFeel()); UIManager.setLookAndFeel(new PlasticLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); } else if (osType == UIHelper.OSTYPE.Linux) { //UIManager.setLookAndFeel(new GTKLookAndFeel()); UIManager.setLookAndFeel(new PlasticLookAndFeel()); //PlasticLookAndFeel.setPlasticTheme(new SkyKrupp()); //PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); //PlasticLookAndFeel.setPlasticTheme(new DesertGreen()); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(UpdatesApp.class, e); System.err.println("Can't change L&F: " + e); //$NON-NLS-1$ } UpdatesApp panel = new UpdatesApp(); JFrame frame = new JFrame(); frame.setTitle("Install4J XML Updater"); frame.setContentPane(panel); JMenuBar menuBar = panel.createMenus(); if (menuBar != null) { //top.add(menuBar, BorderLayout.NORTH); frame.setJMenuBar(menuBar); } frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); } }
From source file:ContructMenuMenuSelectionManager.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 ww w . j a v a2s . c o m // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); newMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MenuElement[] eles = MenuSelectionManager.defaultManager().getSelectedPath(); for (MenuElement ele : eles) { System.out.println(ele); } MenuSelectionManager.defaultManager().clearSelectedPath(); } }); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:ContructMenuWithAction.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 v a 2s.c om fileMenu.addMenuListener(new MenuListener() { public void menuSelected(MenuEvent e) { System.out.println("menuSelected"); } public void menuDeselected(MenuEvent e) { System.out.println("menuDeselected"); } public void menuCanceled(MenuEvent e) { System.out.println("menuCanceled"); } }); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }