List of usage examples for javax.swing JMenu JMenu
public JMenu(Action a)
Action
supplied. From source file:electroStaticUI.ElectroStaticUIContainer.java
private void buildOptionMenu() { /*/* www . ja va2 s . c om*/ * since both graphs are displayed in a JTAbbedPane now there is no need for this... * //create Dimension menu * dimension = new JMenu("Dimension"); * dimension.setMnemonic(KeyEvent.VK_D); * //create 2d menu item * d2d = new JMenuItem("2D"); * d2d.setMnemonic(KeyEvent.VK_2); * d2d.addActionListener(new OptionMenuListener()); * //create 3d menu item * d3d = new JMenuItem("3D"); * d3d.setMnemonic(KeyEvent.VK_3); * d3d.addActionListener(new OptionMenuListener()); * //add dimension choices to it * //dimension.add(d2d); * //dimension.add(d3d); * */ //create Graph menu item graphOptions = new JMenu("Graph"); graphOptions.setMnemonic(KeyEvent.VK_G); //create graphOptions menu items NOTE make one menu item for each and have a single pop up window with fields for all three values. setGraphRangeAndSteps = new JMenuItem("Range/Steps"); setGraphRangeAndSteps.setMnemonic(KeyEvent.VK_S); setGraphRangeAndSteps.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rangeAndStepsSetter(); } }); //add choices to Graph menu graphOptions.add(setGraphRangeAndSteps); //create output menu object optionMenu = new JMenu("Options"); optionMenu.setMnemonic(KeyEvent.VK_O); //add the items to it //optionMenu.add(dimension); optionMenu.add(graphOptions); }
From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxSwing.CFEnSyntaxSwingEnAuxiliaryFinderJInternalFrame.java
public JMenuBar getFinderMenuBar() { if (finderMenuBar == null) { JMenuItem menuItem;//from w w w . j a v a 2 s . c o m finderMenuBar = new JMenuBar(); menuFile = new JMenu("File"); actionAddEnAuxiliary = new ActionAddEnAuxiliary(); menuItem = new JMenuItem(actionAddEnAuxiliary); menuFile.add(menuItem); actionViewSelected = new ActionViewSelectedEnAuxiliary(); menuItem = new JMenuItem(actionViewSelected); menuFile.add(menuItem); actionEditSelected = new ActionEditSelectedEnAuxiliary(); menuItem = new JMenuItem(actionEditSelected); menuFile.add(menuItem); actionDeleteSelected = new ActionDeleteSelectedEnAuxiliary(); menuItem = new JMenuItem(actionDeleteSelected); menuFile.add(menuItem); actionClose = new ActionClose(); menuItem = new JMenuItem(actionClose); menuFile.add(menuItem); finderMenuBar.add(menuFile); } return (finderMenuBar); }
From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.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 w w w . j a v a 2 s . com*/ // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.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) { ResidualPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; ResidualPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help...", new ImageIcon(ResidualPlotAction.class.getResource("/images/action/help-16x16.png"))); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("residual-plot", ResidualPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:ca.sqlpower.swingui.object.VariablesPanel.java
@SuppressWarnings("unchecked") private void showVarsPicker() { final MultiValueMap namespaces = this.variableHelper.getNamespaces(); List<String> sortedNames = new ArrayList<String>(namespaces.keySet().size()); sortedNames.addAll(namespaces.keySet()); Collections.sort(sortedNames, new Comparator<String>() { public int compare(String o1, String o2) { if (o1 == null) { return -1; }//from ww w .ja va2s . c om if (o2 == null) { return 1; } return o1.compareTo(o2); }; }); final JPopupMenu menu = new JPopupMenu(); for (final String name : sortedNames) { final JMenu subMenu = new JMenu(name); menu.add(subMenu); subMenu.addMenuListener(new MenuListener() { private Timer timer; public void menuSelected(MenuEvent e) { subMenu.removeAll(); subMenu.add(new PleaseWaitAction()); ActionListener menuPopulator = new ActionListener() { public void actionPerformed(ActionEvent e) { if (subMenu.isPopupMenuVisible()) { subMenu.removeAll(); for (Object namespaceO : namespaces.getCollection(name)) { String namespace = (String) namespaceO; logger.debug("Resolving variables for namespace ".concat(namespace)); int nbItems = 0; for (String key : variableHelper.keySet(namespace)) { subMenu.add(new InsertVariableAction(SPVariableHelper.getKey((String) key), (String) key)); nbItems++; } if (nbItems == 0) { subMenu.add(new DummyAction()); logger.debug("No variables found."); } } subMenu.revalidate(); subMenu.getPopupMenu().pack(); } } }; timer = new Timer(700, menuPopulator); timer.setRepeats(false); timer.start(); } public void menuDeselected(MenuEvent e) { timer.stop(); } public void menuCanceled(MenuEvent e) { timer.stop(); } }); } menu.show(varNameText, 0, varNameText.getHeight()); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingContactListFinderJInternalFrame.java
public JMenuBar getFinderMenuBar() { if (finderMenuBar == null) { JMenuItem menuItem;//from ww w . j av a2 s . c o m finderMenuBar = new JMenuBar(); menuFile = new JMenu("File"); actionAddContactList = new ActionAddContactList(); menuItem = new JMenuItem(actionAddContactList); menuFile.add(menuItem); actionViewSelected = new ActionViewSelectedContactList(); menuItem = new JMenuItem(actionViewSelected); menuFile.add(menuItem); actionEditSelected = new ActionEditSelectedContactList(); menuItem = new JMenuItem(actionEditSelected); menuFile.add(menuItem); actionDeleteSelected = new ActionDeleteSelectedContactList(); menuItem = new JMenuItem(actionDeleteSelected); menuFile.add(menuItem); actionClose = new ActionClose(); menuItem = new JMenuItem(actionClose); menuFile.add(menuItem); finderMenuBar.add(menuFile); } return (finderMenuBar); }
From source file:PrintCanvas3D.java
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); snapshotItem = new JMenuItem("Snapshot"); snapshotItem.addActionListener(this); printItem = new JMenuItem("Print..."); printItem.addActionListener(this); quitItem = new JMenuItem("Quit"); quitItem.addActionListener(this); fileMenu.add(snapshotItem);/* www . j a v a2 s. c o m*/ fileMenu.add(printItem); fileMenu.add(new JSeparator()); fileMenu.add(quitItem); menuBar.add(fileMenu); return menuBar; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingAccountConfigFinderJInternalFrame.java
public JMenuBar getFinderMenuBar() { if (finderMenuBar == null) { JMenuItem menuItem;//from w w w. j a va 2 s .co m finderMenuBar = new JMenuBar(); menuFile = new JMenu("File"); actionAddAccountConfig = new ActionAddAccountConfig(); menuItem = new JMenuItem(actionAddAccountConfig); menuFile.add(menuItem); actionViewSelected = new ActionViewSelectedAccountConfig(); menuItem = new JMenuItem(actionViewSelected); menuFile.add(menuItem); actionEditSelected = new ActionEditSelectedAccountConfig(); menuItem = new JMenuItem(actionEditSelected); menuFile.add(menuItem); actionDeleteSelected = new ActionDeleteSelectedAccountConfig(); menuItem = new JMenuItem(actionDeleteSelected); menuFile.add(menuItem); actionClose = new ActionClose(); menuItem = new JMenuItem(actionClose); menuFile.add(menuItem); finderMenuBar.add(menuFile); } return (finderMenuBar); }
From source file:daylightchart.gui.DaylightChartGui.java
private void createOptionsMenu(final JMenuBar menuBar, final JToolBar toolBar) { final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.Options")); //$NON-NLS-1$ menu.setMnemonic('O'); final GuiAction options = new OptionsAction(this); menu.add(options);/*w ww . j a v a 2 s. c o m*/ final GuiAction chartOptions = new ChartOptionsAction(this); menu.add(chartOptions); final GuiAction resetAll = new ResetAllAction(this); menu.add(resetAll); menu.addSeparator(); final JCheckBoxMenuItem slimUiMenuItem = new JCheckBoxMenuItem( Messages.getString("DaylightChartGui.Menu.Options.SlimUi")); //$NON-NLS-1$ slimUiMenuItem.setState(isSlimUi()); slimUiMenuItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { final boolean slimUi = e.getStateChange() == ItemEvent.SELECTED; final Options options = UserPreferences.optionsFile().getData(); options.setSlimUi(slimUi); UserPreferences.optionsFile().save(options); ResetAllAction.restart(DaylightChartGui.this, slimUi); } }); menu.add(slimUiMenuItem); menuBar.add(menu); toolBar.add(options); toolBar.add(chartOptions); toolBar.addSeparator(); }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private JMenuBar buildMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); menu.add(new ExcelLoadAction()); menu.add(new SaveParametersAction()); menu.add(new LoadParametersAction()); menu.add(new QuitAction()); menuBar.add(menu);/*w ww . j a v a2s . c o m*/ return menuBar; }
From source file:gdt.jgui.entity.query.JQueryPanel.java
/** * Get the context menu./*from w w w . ja va 2 s . c om*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { menu.removeAll(); // System.out.println("BookmarksEditor:getConextMenu:menu selected"); JMenuItem selectItem = new JMenuItem("Select"); selectItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showHeader(); showContent(); } }); menu.add(selectItem); JMenuItem clearHeader = new JMenuItem("Clear all"); clearHeader.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { clearHeader(); showHeader(); showContent(); } }); menu.add(clearHeader); Entigrator entigrator = console.getEntigrator(entihome$); Sack query = entigrator.getEntityAtKey(entityKey$); if (query.getElementItem("parameter", "noreset") == null) { JMenuItem resetItem = new JMenuItem("Reset"); resetItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Reset source to default ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) reset(); } }); menu.add(resetItem); } JMenuItem folderItem = new JMenuItem("Open folder"); folderItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File file = new File(entihome$ + "/" + entityKey$); Desktop.getDesktop().open(file); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); menu.add(folderItem); menu.addSeparator(); JMenuItem addHeader = new JMenuItem("Add column"); addHeader.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addHeader(); } }); menu.add(addHeader); JMenuItem removeColumn = new JMenuItem("Remove column "); removeColumn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeColumn(); } }); menu.add(removeColumn); ListSelectionModel lsm = table.getSelectionModel(); if (!lsm.isSelectionEmpty()) { JMenuItem excludeRows = new JMenuItem("Exclude rows "); excludeRows.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Entigrator entigrator = console.getEntigrator(entihome$); Sack query = entigrator.getEntityAtKey(entityKey$); if (!query.existsElement("exclude")) query.createElement("exclude"); //else // query.clearElement("exclude"); ListSelectionModel lsm = table.getSelectionModel(); int minIndex = lsm.getMinSelectionIndex(); int maxIndex = lsm.getMaxSelectionIndex(); for (int i = minIndex; i <= maxIndex; i++) { if (lsm.isSelectedIndex(i)) { System.out.println("JQueryPanel:exclude rows:label=" + table.getValueAt(i, 1)); query.putElementItem("exclude", new Core(null, (String) table.getValueAt(i, 1), null)); } } entigrator.save(query); showHeader(); showContent(); } }); menu.add(excludeRows); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }