List of usage examples for javax.swing JMenuBar add
public JMenu add(JMenu c)
From source file:Main.java
public JMenuBar createMenuBar() { JMenuBar top_menu_bar = new JMenuBar(); JMenu main_menu = new JMenu("Menu"); main_menu.setMnemonic(KeyEvent.VK_M); top_menu_bar.add(main_menu); JMenuItem menu_item;/*from ww w . j a v a 2 s . c o m*/ menu_item = new JMenuItem("Add New"); menu_item.setMnemonic(KeyEvent.VK_N); menu_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.ALT_MASK)); menu_item.setActionCommand("new"); menu_item.addActionListener(e -> createThumb()); main_menu.add(menu_item); return top_menu_bar; }
From source file:com.planetmayo.debrief.satc.util.StraightLineCullingTestForm.java
private void createMenu() { JMenu menu = new JMenu("File"); menu.add(new AbstractAction("Load") { private static final long serialVersionUID = 1L; @Override//from www .ja v a 2 s. c o m public void actionPerformed(ActionEvent e) { if (fc.showOpenDialog(StraightLineCullingTestForm.this) == JFileChooser.APPROVE_OPTION) { try { loadFile(fc.getSelectedFile()); } catch (IOException ex) { } } } }); JMenuBar menuBar = new JMenuBar(); menuBar.add(menu); setJMenuBar(menuBar); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);/* www .j a v a2s .c o m*/ add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.doClick(100); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);/*from w w w.j av a 2s.co m*/ add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); MenuElement[] e = menu.getSubElements(); }
From source file:at.tuwien.ifs.commons.gui.controls.MultiOptionToggleButton.java
public MultiOptionToggleButton(final ImageIcon[] icons, final String[] buttonTexts, final String tooltip, final MultiOptionToggleListener listener) { super(icons[0]); this.setToolTipText(tooltip); this.addActionListener(new ActionListener() { @Override//from w ww .j ava 2s . c om public void actionPerformed(ActionEvent e) { menu.show(MultiOptionToggleButton.this, 0, MultiOptionToggleButton.this.getHeight()); // highlight current selection final Component[] components = menu.getComponents(); for (Component c : components) { c.setBackground(null); } menu.getComponent(selectedIndex).setBackground(Color.GRAY); } }); for (int i = 0; i < buttonTexts.length; i++) { JMenuItem jMenuItem = new JMenuItem(buttonTexts[i], icons[i]); jMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { listener.performAction(e.getActionCommand()); selectedIndex = ArrayUtils.indexOf(buttonTexts, e.getActionCommand()); setIcon(icons[selectedIndex]); } }); menu.add(jMenuItem); } JMenuBar menuBar = new JMenuBar(); menuBar.setBorderPainted(false); menuBar.add(menu); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);//from w w w . j av a 2s . com add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.insert(new JMenuItem("Exit"), 0); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);//from w w w. jav a 2 s. c o m add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.isSelected(); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);/*from ww w.java 2s. c o m*/ add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.insert("Exit", 0); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);//from w ww . j a va2 s.c om add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.isPopupMenuVisible(); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu); menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar);/*from www .j av a 2s .c o m*/ add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); menu.insertSeparator(0); }