List of usage examples for javax.swing JMenu add
public JMenuItem add(Action a)
From source file:de.tbuchloh.kiskis.gui.MainFramePanel.java
protected static void addActions(final JMenu fileMenu, final Action[] actions) { for (int i = 0; i < actions.length; ++i) { if (actions[i] == null) { fileMenu.addSeparator();/*from w ww . j a v a 2 s .c o m*/ } else { fileMenu.add(actions[i]); } } }
From source file:de.freese.base.swing.mac_os_x.MyApp.java
/** * */// w ww . j a va2s . co m public void addMenus() { JMenu fileMenu = new JMenu("File"); JMenuBar mainMenuBar = new JMenuBar(); mainMenuBar.add(fileMenu = new JMenu("File")); fileMenu.add(this.openMI = new JMenuItem("Open...")); this.openMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_MASK)); this.openMI.addActionListener(this); // Quit/prefs menu items are provided on Mac OS X; only add your own on other platforms if (!IS_OS_MAC_OSX) { fileMenu.addSeparator(); fileMenu.add(this.optionsMI = new JMenuItem("Options")); this.optionsMI.addActionListener(this); fileMenu.addSeparator(); fileMenu.add(this.quitMI = new JMenuItem("Quit")); this.quitMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, MENU_MASK)); this.quitMI.addActionListener(this); } mainMenuBar.add(this.helpMenu = new JMenu("Help")); this.helpMenu.add(this.docsMI = new JMenuItem("Online Documentation")); this.helpMenu.addSeparator(); this.helpMenu.add(this.supportMI = new JMenuItem("Technical Support")); // About menu item is provided on Mac OS X; only add your own on other platforms if (!IS_OS_MAC_OSX) { this.helpMenu.addSeparator(); this.helpMenu.add(this.aboutMI = new JMenuItem("About OSXAdapter")); this.aboutMI.addActionListener(this); } setJMenuBar(mainMenuBar); }
From source file:com.haskins.cloudtrailviewer.sidebar.AbstractChart.java
private void addStyleMenu() { JRadioButtonMenuItem mnuPie = new JRadioButtonMenuItem("Pie"); JRadioButtonMenuItem mnuPie3d = new JRadioButtonMenuItem("Pie 3D"); JRadioButtonMenuItem mnuBar = new JRadioButtonMenuItem("Bar"); JRadioButtonMenuItem mnuBar3d = new JRadioButtonMenuItem("Bar 3d"); mnuPie.setActionCommand("style.Pie"); mnuPie.addActionListener(this); mnuPie.setSelected(true);//from w w w .j a va 2 s . c om mnuPie3d.setActionCommand("style.Pie3d"); mnuPie3d.addActionListener(this); mnuBar.setActionCommand("style.Bar"); mnuBar.addActionListener(this); mnuBar3d.setActionCommand("style.Bar3d"); mnuBar3d.addActionListener(this); styleGroup.add(mnuPie); styleGroup.add(mnuPie3d); styleGroup.add(mnuBar); styleGroup.add(mnuBar3d); JMenu menuStyle = new JMenu("Style"); menuStyle.add(mnuPie); menuStyle.add(mnuPie3d); menuStyle.add(mnuBar); menuStyle.add(mnuBar3d); menu.add(menuStyle); }
From source file:com.haskins.cloudtrailviewer.sidebar.AbstractChart.java
private void addOrientationMenu() { JRadioButtonMenuItem mnuHorizontal = new JRadioButtonMenuItem("Horizontal"); JRadioButtonMenuItem mnuVertical = new JRadioButtonMenuItem("Vertical"); mnuHorizontal.setActionCommand("orientation.horizontal"); mnuHorizontal.addActionListener(this); mnuHorizontal.setSelected(true);//from w w w .j av a2s . c o m mnuVertical.setActionCommand("orientation.vertical"); mnuVertical.addActionListener(this); orientationGroup.add(mnuHorizontal); orientationGroup.add(mnuVertical); JMenu menuOrientation = new JMenu("Orientation"); menuOrientation.add(mnuHorizontal); menuOrientation.add(mnuVertical); menu.add(menuOrientation); }
From source file:com.game.ui.views.MapEditor.java
public void generateGUI() throws IOException { setDefaultCloseOperation(DISPOSE_ON_CLOSE); // setResizable(false); JMenuBar menubar = new JMenuBar(); ImageIcon icon = null;/*from ww w. j av a 2 s . c om*/ try { icon = GameUtils.shrinkImage("save.png", 20, 20); } catch (IOException e) { System.out.println("Dialog : showDialogForMap(): Exception occured :" + e); e.printStackTrace(); } JMenu file = new JMenu("File"); JMenuItem save = new JMenuItem("Save", icon); save.setToolTipText("Save Map Information"); save.setActionCommand("Save Map"); save.addActionListener(this); file.add(save); menubar.add(file); setJMenuBar(menubar); JPanel topPanel = new JPanel(); topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); topPanel.setLayout(new GridBagLayout()); JLabel headerLbl = new JLabel("Legend : "); headerLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); JLabel lbl1 = new JLabel(); lbl1.setPreferredSize(new Dimension(50, 20)); lbl1.setBackground(Configuration.pathColor); lbl1.setOpaque(true); JLabel lbl2 = new JLabel("- Represents the path."); JLabel lbl3 = new JLabel(); lbl3.setPreferredSize(new Dimension(50, 20)); lbl3.setBackground(Configuration.enemyColor); lbl3.setOpaque(true); JLabel lbl4 = new JLabel("- Represents the path with monsters"); JLabel lbl5 = new JLabel(); lbl5.setPreferredSize(new Dimension(50, 20)); lbl5.setBackground(Configuration.startPointColor); lbl5.setOpaque(true); JLabel lbl6 = new JLabel("- Represents the starting point in the path"); JLabel lbl7 = new JLabel(); lbl7.setBackground(Configuration.endPointColor); lbl7.setOpaque(true); lbl7.setPreferredSize(new Dimension(50, 20)); JLabel lbl8 = new JLabel("- Ending point in the path"); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.weightx = 1; c.weighty = 0; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 2; topPanel.add(headerLbl, c); c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = 1; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.ipadx = 5; c.ipady = 5; topPanel.add(lbl1, c); c.gridx = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; topPanel.add(lbl2, c); c.gridx = 0; c.gridy = 2; topPanel.add(lbl3, c); c.gridx = 1; topPanel.add(lbl4, c); c.gridx = 0; c.gridy = 3; topPanel.add(lbl5, c); c.gridx = 1; topPanel.add(lbl6, c); c.gridx = 0; c.gridy = 4; topPanel.add(lbl7, c); c.gridx = 1; topPanel.add(lbl8, c); add(topPanel, BorderLayout.NORTH); bottomPanel = new JPanel(); add(bottomPanel, BorderLayout.CENTER); bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); // bottomPanel.add(new JButton("kaushik")); pack(); setExtendedState(JFrame.MAXIMIZED_BOTH); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); setMaximizedBounds(env.getMaximumWindowBounds()); setVisible(true); callDialogForUsersInput(); }
From source file:MenuAcceleratorKeyStroke.java
public MenuAcceleratorKeyStroke() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); menu.setMnemonic('f'); bar.add(menu);//from www. j av a 2 s. c om JMenuItem exit = new JMenuItem("Exit"); exit.setMnemonic('x'); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Exit performed"); MenuAcceleratorKeyStroke.this.dispose(); System.exit(0); } }); menu.add(exit); menu = new JMenu("Edit"); menu.setMnemonic('e'); bar.add(menu); EditListener l = new EditListener(); JMenuItem mi; mi = menu.add(new JMenuItem("Cut", 't')); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); mi.addActionListener(l); mi = menu.add(new JMenuItem("Copy", 'c')); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); mi.addActionListener(l); mi = menu.add(new JMenuItem("Paste", 'p')); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); mi.addActionListener(l); setJMenuBar(bar); getContentPane().add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); }
From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
private JMenu createFileMenu() { JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); JMenuItem fileExit = new JMenuItem("Exit"); fileExit.setMnemonic('x'); fileExit.setActionCommand("exit"); fileExit.addActionListener(actionMapper); fileMenu.add(fileExit); return fileMenu; }
From source file:ec.ui.chart.RevisionChartPanel.java
private JMenu buildMenu() { am = new ActionMap(); am.put(COPY_ACTION, new CopyAction()); im = new InputMap(); KeyStrokes.putAll(im, KeyStrokes.COPY, COPY_ACTION); JMenu result = new JMenu(); JMenuItem item;/*from w w w.j av a2 s . com*/ item = new JMenuItem(am.get(COPY_ACTION)); item.setText("Copy All"); item.setAccelerator(KeyStrokes.COPY.get(0)); ExtAction.hideWhenDisabled(item); result.add(item); return result; }
From source file:net.adamjak.thomas.graph.application.gui.ResultsWidnow.java
private JMenuBar createJMenuBar() { this.jMenuBar = new JMenuBar(); // Menu File/*from w ww. j av a2 s . c om*/ JMenu jmFile = new JMenu("File"); JMenuItem jmiFileSaveResults = new JMenuItem("Save results"); jmiFileSaveResults.setAccelerator(GuiAccelerators.CTRL_S); jmiFileSaveResults.addActionListener(new AlJmiFileSaveResults()); jmFile.add(jmiFileSaveResults); //jmFile.addSeparator(); this.jMenuBar.add(jmFile); return this.jMenuBar; }
From source file:com.simplexrepaginator.RepaginateFrame.java
protected JMenuBar createMenuBar() { JMenuBar mb = new JMenuBar(); JMenu m; m = new JMenu("File"); m.add(new AbstractAction("Select Input") { @Override/* w w w . j a v a 2 s . c o m*/ public void actionPerformed(ActionEvent e) { input.doClick(); } }); m.add(new AbstractAction("Select Output") { @Override public void actionPerformed(ActionEvent e) { output.doClick(); } }); m.add(new UpdateCheckerAction()); m.add(new AbstractAction("Exit") { @Override public void actionPerformed(ActionEvent arg0) { dispose(); } }); mb.add(m); m = new JMenu("Help"); m.add(new AbstractAction("Website") { @Override public void actionPerformed(ActionEvent e) { try { URL url = new URL("http://www.simplexrepaginator.com/"); Desktop.getDesktop().browse(url.toURI()); } catch (IOException ioe) { } catch (URISyntaxException urise) { } } }); m.add(new AbstractAction("About") { @Override public void actionPerformed(ActionEvent e) { String license; try { license = IOUtils.toString(RepaginateFrame.class.getResource("LICENSE.txt")); } catch (IOException ioe) { license = "An error occured reading the license file:\n" + ioe; } JOptionPane.showMessageDialog(RepaginateFrame.this, license); } }); mb.add(m); return mb; }