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(final String args[]) { Action action = new AbstractAction("CheckBox Label") { public void actionPerformed(ActionEvent evt) { System.out.println("called"); }/*www. j a v a 2 s . co m*/ }; 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); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem(action); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); 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", false); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);//from w w w. j a v a2 s.co m // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem("Case Sensitive"); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); 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);/* w ww . j ava 2 s .co m*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem(new MyIcon(Color.RED)); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); 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 . ja v a2s.com*/ // 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); }
From source file:SwingTest.java
/** * main entry point for the application. Creates the parent JFrame, the * JMenuBar and creates the JPanel which is the application itself. */// w ww . j a v a2s .c om public static void main(String[] args) { JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.setLightWeightPopupEnabled(false); JFrame frame = new JFrame(); SwingTest swingTest = new SwingTest(); frame.setJMenuBar(swingTest.createMenuBar()); frame.getContentPane().add(swingTest); frame.setSize(550, 550); registerWindowListener(frame); 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 2s . c o m*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem("Item", new MyIcon(Color.RED)); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.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(); JMenu menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem("A"); group.add(menuItem);/*from w w w . j a v a 2s .c o m*/ 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); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }
From source file:external.jung.demo.RoadEditorDemo.java
/** * a driver for this demo//from www .j a va2s .c om */ @SuppressWarnings("serial") public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final RoadEditorDemo demo = new RoadEditorDemo(); JMenu menu = new JMenu("File"); JPopupMenu.setDefaultLightWeightPopupEnabled(false); JMenuBar menuBar = new JMenuBar(); menuBar.add(menu); frame.setJMenuBar(menuBar); frame.getContentPane().add(demo); frame.pack(); 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);//w ww .ja v a 2 s .co m // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem("Item", new MyIcon(Color.RED), true); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.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 w ww. java 2s . co 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); f.setJMenuBar(bar); f.setSize(300, 200); f.setVisible(true); }