List of usage examples for javax.swing JMenu add
public JMenuItem add(Action a)
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private JMenu createExportDrawingMenu() { JMenu export_menu = new JMenu("Export to graphical formats"); export_menu.setIcon(FileUtils.defaultThemeManager.getImageIcon("export")); for (Map.Entry<String, String> e : SVGUtils.getExportFormats().entrySet()) export_menu.add(theActionManager.get("export=" + e.getKey())); return export_menu; }
From source file:net.chaosserver.timelord.swingui.TimelordMenu.java
/** * Creates the task menu.// w w w. j a v a 2 s. com * * @return the new task menu */ protected JMenu createTaskMenu() { JMenuItem menuItem; JMenu taskMenu = new JMenu("Task"); taskMenu.setMnemonic(KeyEvent.VK_T); this.add(taskMenu); menuItem = new JMenuItem("New Task", KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_ADDTASK); menuItem.addActionListener(this); taskMenu.add(menuItem); menuItem = new JMenuItem("Hide Old Tasks", KeyEvent.VK_H); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_HIDETASK); menuItem.addActionListener(this); taskMenu.add(menuItem); menuItem = new JMenuItem("Unhide Task", KeyEvent.VK_U); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_UNHIDETASK); menuItem.addActionListener(this); taskMenu.add(menuItem); taskMenu.addSeparator(); menuItem = new JMenuItem("Add Time", KeyEvent.VK_A); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_ADDTIME); menuItem.addActionListener(this); taskMenu.add(menuItem); menuItem = new JMenuItem("Find Task", KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_FINDTASK); menuItem.addActionListener(this); taskMenu.add(menuItem); return taskMenu; }
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Create the Sleep for... Menu.// ww w . j a v a2 s . c o m * * @return the Sleep Menu */ protected JMenu sleepMenu() { JMenu jms = new JMenu(KstatResources.getString("SLEEP.TEXT")); jms.setMnemonic(KeyEvent.VK_U); sleepItem1 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.1")); sleepItem1.addActionListener(this); sleepItem2 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.2")); sleepItem2.addActionListener(this); sleepItem5 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.5"), true); sleepItem5.addActionListener(this); sleepItem10 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.10")); sleepItem10.addActionListener(this); jms.add(sleepItem1); jms.add(sleepItem2); jms.add(sleepItem5); jms.add(sleepItem10); ButtonGroup sleepGroup = new ButtonGroup(); sleepGroup.add(sleepItem1); sleepGroup.add(sleepItem2); sleepGroup.add(sleepItem5); sleepGroup.add(sleepItem10); return jms; }
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private JMenu buildMenu() { JMenu menu = new JMenu(); JMenuItem back = new JMenuItem(new AbstractAction("Show complete data...") { @Override/* w w w .j a v a 2 s . co m*/ public void actionPerformed(ActionEvent e) { showMain(); indexSelected = -1; } }); menu.add(back); JMenuItem item = new JMenuItem(new CopyDetailAction()); item.setText("Copy current data"); menu.add(item); return menu; }
From source file:com.haulmont.cuba.desktop.App.java
protected Container createStartContentPane() { JPanel pane = new JPanel(new BorderLayout()); menuBar = new JMenuBar(); pane.add(menuBar, BorderLayout.NORTH); Locale loc = Locale.getDefault(); JMenu menu = new JMenu(messages.getMainMessage("mainMenu.file", loc)); menuBar.add(menu);/*from w ww. j ava 2 s. c om*/ JMenuItem item; item = new JMenuItem(messages.getMainMessage("mainMenu.connect", loc)); item.addActionListener(e -> showLoginDialog()); menu.add(item); item = new JMenuItem(messages.getMainMessage("mainMenu.exit", loc)); item.addActionListener(new ValidationAwareActionListener() { @Override public void actionPerformedAfterValidation(ActionEvent e) { exit(); } }); menu.add(item); if (isTestMode()) { menuBar.setName("startMenu"); } return pane; }
From source file:net.chaosserver.timelord.swingui.TimelordMenu.java
/** * Creates the file menu.//from w w w.ja v a 2s .c o m * * @return the new file menu */ protected JMenu createFileMenu() { JMenu fileMenu = new JMenu(resourceBundle.getString(RROOT + ".fileMenuName")); JMenuItem menuItem; fileMenu.setMnemonic(KeyEvent.VK_F); JMenu exportMenu = new JMenu(resourceBundle.getString(RROOT + ".file.export")); exportMenu.setMnemonic(KeyEvent.VK_A); menuItem = new JMenuItem(resourceBundle.getString(RROOT + ".file.export.jordan"), KeyEvent.VK_J); menuItem.setToolTipText(resourceBundle.getString(RROOT + ".file.export.jordan.tooltip")); menuItem.setActionCommand(ACTION_EXPORT_JORDAN); menuItem.addActionListener(this); exportMenu.add(menuItem); menuItem = new JMenuItem(resourceBundle.getString(RROOT + ".file.export.doug"), KeyEvent.VK_D); menuItem.setToolTipText("For Losers"); menuItem.setActionCommand(ACTION_EXPORT_DOUG); menuItem.addActionListener(this); exportMenu.add(menuItem); exportMenu.addSeparator(); menuItem = new JMenuItem("XML...", KeyEvent.VK_X); menuItem.setActionCommand(ACTION_EXPORT_XML); menuItem.addActionListener(this); exportMenu.add(menuItem); fileMenu.add(exportMenu); if (!OsUtil.isMac()) { fileMenu.addSeparator(); menuItem = new JMenuItem("Exit", KeyEvent.VK_X); menuItem.setActionCommand(ACTION_EXIT); menuItem.addActionListener(this); fileMenu.add(menuItem); } return fileMenu; }
From source file:net.sf.nmedit.jtheme.component.JTModuleContainer.java
public void installModulesMenu(JPopupMenu menu) { PModuleContainer container = getModuleContainer(); ModuleDescriptions modules = getModuleContainer().getPatch().getModuleDescriptions(); Map<String, List<PModuleDescriptor>> categoryMap = new HashMap<String, List<PModuleDescriptor>>(); for (PModuleDescriptor module : modules) { if (module.isInstanciable() && container.canAdd(module)) { String cat = module.getCategory(); List<PModuleDescriptor> catList = categoryMap.get(cat); if (catList == null) { catList = new ArrayList<PModuleDescriptor>(); categoryMap.put(cat, catList); }/*from www. ja v a2 s . c om*/ catList.add(module); } } Comparator<PModuleDescriptor> order = new DescriptorNameComparator<PModuleDescriptor>(); List<String> categories = new ArrayList<String>(); categories.addAll(categoryMap.keySet()); Collections.sort(categories); for (String cat : categories) { List<PModuleDescriptor> catList = categoryMap.get(cat); Collections.sort(catList, order); JMenu catMenu = new JMenu(cat); for (PModuleDescriptor m : catList) { catMenu.add(new InsertModuleAction(m, this)); } menu.add(catMenu); } }
From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java
/** * * @return Create the menu that allows load the result from others * experiments.// w w w .ja va 2 s .co m */ private JMenu createMenu() { final JMenu fileMenu = new JMenu("Options"); final JFileChooser f = new JFileChooser(); f.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileMenu.add("Add report file or directory").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (curveOptions != null) { curveOptions.setVisible(false); curveOptions = null; } int action = f.showOpenDialog(fileMenu); if (action == JFileChooser.APPROVE_OPTION) { loadReportFile(f.getSelectedFile()); } } }); fileMenu.add("Area under learning curve (ALC)").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (comboBox.getItemCount() != 0) { if (!comboBox.getSelectedItem().toString().isEmpty()) { StringBuilder st = new StringBuilder(); st.append("Measure: ").append(comboBox.getSelectedItem()).append("\n\n"); for (int query = 0; query < queryNames.size(); query++) { double value = LearningCurveUtility.getArea(evaluationsCollection.get(query), comboBox.getSelectedItem().toString()); String valueString = String.format("%.3f", value); st.append(queryNames.get(query)).append(": ").append(valueString).append("\n"); } JOptionPane.showMessageDialog(content, st.toString(), "Area under the learning curve", JOptionPane.INFORMATION_MESSAGE); } } } }); fileMenu.add("Clear").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { queryNames = new ArrayList<String>(); evaluationsCollection = new ArrayList<List<AbstractEvaluation>>(); comboBox.removeAllItems(); controlCurveColor = new HashMap<String, Color>(); colors.clear(); data = null; set.clear(); curveOptions.setVisible(false); curveOptions = null; setSeries.clear(); passiveEvaluation = null; } }); fileMenu.add("Curve options").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { data = informationTable(); if (queryNames.isEmpty()) { JOptionPane.showMessageDialog(null, "Please add curves"); return; } if (curveOptions == null) { curveOptions = new LearningCurvesVisualTable(ExternalBasicChart.this); } else { curveOptions.setVisible(true); } } }); final JCheckBox viewPoints = new JCheckBox("View points's shapes"); viewPoints.setSelected(false); viewPoints.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { viewPointsForm = viewPoints.isSelected(); jComboBoxItemStateChanged(); } }); fileMenu.add(viewPoints); final JCheckBox withOutColor = new JCheckBox("View without color"); withOutColor.setSelected(false); withOutColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { viewWithOutColor = withOutColor.isSelected(); jComboBoxItemStateChanged(); } }); fileMenu.add(withOutColor); return fileMenu; }
From source file:com.github.fritaly.dualcommander.DualCommander.java
public DualCommander() { // TODO Generate a fat jar at build time super(String.format("Dual Commander %s", Utils.getApplicationVersion())); if (logger.isInfoEnabled()) { logger.info(String.format("Dual Commander %s", Utils.getApplicationVersion())); }/*from w w w . j av a 2s. c o m*/ try { // Apply the JGoodies L&F UIManager.setLookAndFeel(new WindowsLookAndFeel()); } catch (Exception e) { // Not supposed to happen } // Layout, columns & rows setLayout(new MigLayout("insets 0px", "[grow]0px[grow]", "[grow]0px[]")); // Create a menu bar final JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(preferencesAction)); fileMenu.add(new JSeparator()); fileMenu.add(new JMenuItem(quitAction)); final JMenu helpMenu = new JMenu("Help"); helpMenu.add(new JMenuItem(aboutAction)); final JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); this.leftPane = new TabbedPane(preferences); this.leftPane.setName("Left"); this.leftPane.addChangeListener(this); this.leftPane.addKeyListener(this); this.leftPane.addFocusListener(this); this.rightPane = new TabbedPane(preferences); this.rightPane.setName("Right"); this.rightPane.addChangeListener(this); this.rightPane.addKeyListener(this); this.rightPane.addFocusListener(this); // Adding the 2 components to the same sizegroup ensures they always // keep the same width getContentPane().add(leftPane, "grow, sizegroup g1"); getContentPane().add(rightPane, "grow, sizegroup g1, wrap"); // The 7 buttons must all have the same width (they must belong to the // same size group) final JPanel buttonPanel = new JPanel( new MigLayout("insets 0px", StringUtils.repeat("[grow, sizegroup g1]", 7), "[grow]")); buttonPanel.add(viewButton, "grow"); buttonPanel.add(editButton, "grow"); buttonPanel.add(copyButton, "grow"); buttonPanel.add(moveButton, "grow"); buttonPanel.add(mkdirButton, "grow"); buttonPanel.add(deleteButton, "grow"); buttonPanel.add(quitButton, "grow"); getContentPane().add(buttonPanel, "grow, span 2"); // Register shortcuts at a global level (not on every component) final InputMap inputMap = this.leftPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, true), "view"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0, true), "edit"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true), "copy"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0, true), "move"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0, true), "mkdir"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0, true), "delete"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK), "quit"); final ActionMap actionMap = this.leftPane.getActionMap(); actionMap.put("view", viewAction); actionMap.put("edit", editAction); actionMap.put("copy", copyAction); actionMap.put("move", moveAction); actionMap.put("mkdir", mkdirAction); actionMap.put("delete", deleteAction); actionMap.put("quit", quitAction); addWindowListener(this); addKeyListener(this); // Listen to preference change events this.preferences.addPropertyChangeListener(this); // Reload the last configuration and init the left & right panels // accordingly final Preferences prefs = Preferences.userNodeForPackage(this.getClass()); // The user preferences must be loaded first because they're needed to // init the UI this.preferences.init(prefs.node("user.preferences")); this.leftPane.init(prefs.node("left.panel")); this.rightPane.init(prefs.node("right.panel")); if (logger.isInfoEnabled()) { logger.info("Loaded preferences"); } // Init the buttons refreshButtons(this.leftPane.getActiveBrowser().getSelection()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setExtendedState(JFrame.MAXIMIZED_BOTH); if (logger.isInfoEnabled()) { logger.info("UI initialized"); } }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);/*from ww w . j a v a 2 s . co m*/ // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Clear Selections") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.setSelectedIndices(new int[0]); } }); toolsMenu.addSeparator(); ButtonGroup dragButtonGroup = new ButtonGroup(); JCheckBoxMenuItem selectModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Select"); selectModeCheckBox.setSelected(true); this.dragToSelect = true; selectModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToSelect = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(selectModeCheckBox); toolsMenu.add(selectModeCheckBox); JCheckBoxMenuItem zoomModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Zoom"); zoomModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToZoom = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(zoomModeCheckBox); toolsMenu.add(zoomModeCheckBox); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; VolcanoPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); toolsMenu.addSeparator(); toolsMenu.add(this.displayTestResultsAction); toolsMenu.addSeparator(); toolsMenu.add(this.saveSelectedPointsMenuItem); JMenu selectPointsFromLisMenu = new JMenu("Select Points From Gene List"); List<String> geneListNames = this.maanovaTestResult.getParentExperiment().getGeneListNames(); if (geneListNames.isEmpty()) { JMenuItem noListsMenuItem = new JMenuItem("No Gene Lists Available"); noListsMenuItem.setEnabled(false); selectPointsFromLisMenu.add(noListsMenuItem); } else { for (final String geneListName : geneListNames) { JMenuItem currGeneListMenuItem = new JMenuItem( RUtilities.fromRIdentifierToReadableName(geneListName)); currGeneListMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.selectedIndicesFromGeneList(geneListName); } }); selectPointsFromLisMenu.add(currGeneListMenuItem); } } toolsMenu.add(selectPointsFromLisMenu); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(VolcanoPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("volcano-plot", VolcanoPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }