List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
From source file:de.burrotinto.jKabel.dispalyAS.DisplayAAS.java
private JMenu getjTypSortMenu() { JMenu typSortMenu = new JMenu("Typ Sortierung"); JRadioButtonMenuItem inOrder = new JRadioButtonMenuItem("Aufsteigend Sortieren"); inOrder.setSelected(ConfigReader.getInstance().isTypeInOrder()); inOrder.addActionListener(new ActionListener() { @Override/* ww w.j a va 2 s.c o m*/ public void actionPerformed(ActionEvent actionEvent) { try { ConfigReader.getInstance().setTypeInOrder(inOrder.isSelected()); // if (kabelTypAuswahlAAS != null) { // kabelTypAuswahlAAS.typSelected(kabelTypAuswahlAAS.getSelected()); // } } catch (IOException e) { e.printStackTrace(); } } }); typSortMenu.add(inOrder); typSortMenu.addSeparator(); ButtonGroup group = new ButtonGroup(); for (AbstractTypeSort aTS : ConfigReader.getInstance().getAllTypSort()) { JRadioButtonMenuItem sw = new JRadioButtonMenuItem(aTS.getName()); sw.setSelected(aTS.equals(ConfigReader.getInstance().getKabeltypSort())); group.add(sw); typSortMenu.add(sw); sw.addActionListener(aTS); } return typSortMenu; }
From source file:de.burrotinto.jKabel.dispalyAS.DisplayAAS.java
private JMenu getjTrommelSortMenu() { JMenu trommelSortMenu = new JMenu("Trommel Sortierung"); JRadioButtonMenuItem inOrder = new JRadioButtonMenuItem("Aufsteigend Sortieren"); inOrder.setSelected(ConfigReader.getInstance().isTypeInOrder()); inOrder.addActionListener(new ActionListener() { @Override//from w w w.j a va 2s .c o m public void actionPerformed(ActionEvent actionEvent) { try { ConfigReader.getInstance().setTrommelInOrder(inOrder.isSelected()); // if (kabelTypAuswahlAAS != null) { // kabelTypAuswahlAAS.typSelected(kabelTypAuswahlAAS.getSelected()); // } } catch (IOException e) { e.printStackTrace(); } } }); trommelSortMenu.add(inOrder); trommelSortMenu.addSeparator(); ButtonGroup group = new ButtonGroup(); for (AbstractTrommelSort aTS : ConfigReader.getInstance().getAllTrommelSort()) { JRadioButtonMenuItem sw = new JRadioButtonMenuItem(aTS.getName()); sw.setSelected(aTS.equals(ConfigReader.getInstance().getTrommelSort())); group.add(sw); trommelSortMenu.add(sw); sw.addActionListener(aTS); } return trommelSortMenu; }
From source file:com.mightypocket.ashot.Mediator.java
private JMenuBar createMenuBar() { BindingGroup menuBinding = new BindingGroup(); ResourceMap resourceMap = application.getContext().getResourceMap(Mediator.class); ApplicationActionMap actionMap = getActionMap(); JMenuBar bar = new JMenuBar(); // Menu File//from w ww. j a v a 2s . c om JMenu menuFile = new JMenu(resourceMap.getString("menu.file")); menuFileDevices = new JMenu(resourceMap.getString("menu.file.devices.text")); menuFileDevices.setIcon(resourceMap.getIcon("menu.file.devices.icon")); menuFile.add(menuFileDevices); menuBinding.addBinding(bindRead(this, PROP_DEVICES, menuFileDevices, "enabled")); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get(ACTION_SAVE_SCREENSHOT))); menuFile.add(new JCheckBoxMenuItem(actionMap.get(ACTION_RECORDING))); menuFile.add(new JMenuItem(actionMap.get(ACTION_OPEN_DESTINATION_FOLDER))); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get(ACTION_CHANGE_DEFAULT_FOLDER))); menuFile.add(new JMenuItem(actionMap.get(ACTION_CHANGE_SDK_FOLDER))); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get("quit"))); // Menu Edit JMenu menuEdit = new JMenu(resourceMap.getString("menu.edit")); menuEdit.add(new JMenuItem(actionMap.get(ACTION_COPY_TO_CLIPBOARD))); // Menu View JMenu menuView = new JMenu(resourceMap.getString("menu.view")); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_SHOW_TOOLBAR_LABELS))); menuView.addSeparator(); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_LANDSCAPE))); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_LANDSCAPE_CW))); menuView.addSeparator(); menuView.add(new JMenuItem(actionMap.get(ACTION_ZOOM_IN))); menuView.add(new JMenuItem(actionMap.get(ACTION_ZOOM_OUT))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_ORIGINAL))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_SMALL))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_LARGE))); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_SIZE_FIT))); menuView.addSeparator(); menuView.add(new JMenuItem(actionMap.get(ACTION_FULL_SCREEN))); // Menu Tools JMenu toolsView = new JMenu(resourceMap.getString("menu.tools")); toolsView.add(new JMenuItem(actionMap.get(ACTION_INSTALL))); toolsView.addSeparator(); toolsView.add(new JMenuItem(actionMap.get(ACTION_OPTIONS))); // Menu Help JMenu menuHelp = new JMenu(resourceMap.getString("menu.help")); menuHelp.add(new JMenuItem(actionMap.get(ACTION_CHECK_UPDATES))); menuHelp.add(new JMenuItem(actionMap.get(ACTION_ABOUT))); bar.add(menuFile); bar.add(menuEdit); bar.add(menuView); bar.add(toolsView); bar.add(menuHelp); menuBinding.bind(); return bar; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
private void buildFileMenu(JMenu mnuFile) { mnuFile.removeAll();/*from w w w .ja v a2 s . c om*/ String[] fileMenuActions = { "newFile", "loadFile", "closeFile", "-", "saveFile", "saveAsFile", "-", "importDirectives", "exportDirectives" }; MenuBuilder.buildMenu(mnuFile, fileMenuActions, _actionMap); mnuFile.addSeparator(); String[] previous = EditorPreferences.getPreviouslyUsedFiles(); if (previous != null && previous.length > 0) { javax.swing.Action a = this._actionMap.get("loadPreviousFile"); if (a != null) { for (int i = 0; i < previous.length; ++i) { String filename = previous[i]; JMenuItem item = new JMenuItem(); item.setAction(a); item.setText(String.format("%d %s", i + 1, filename)); item.putClientProperty("Filename", filename); item.setMnemonic(KeyEvent.VK_1 + i); mnuFile.add(item); } } } if (!isMac()) { mnuFile.addSeparator(); JMenuItem mnuItFileExit = new JMenuItem(); mnuItFileExit.setAction(_actionMap.get("exitApplication")); mnuFile.add(mnuItFileExit); } }
From source file:net.chaosserver.timelord.swingui.TimelordMenu.java
/** * Creates the file menu./*from w w w. j av a 2 s . com*/ * * @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:ToolbarDemo.java
protected JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenu mFile = new JMenu("File"); mFile.setMnemonic('f'); ImageIcon iconNew = new ImageIcon("file_new.gif"); Action actionNew = new AbstractAction("New", iconNew) { public void actionPerformed(ActionEvent e) { System.out.println("new action"); }/*from w ww . ja v a 2 s.c om*/ }; JMenuItem item = mFile.add(actionNew); mFile.add(item); ImageIcon iconOpen = new ImageIcon("file_open.gif"); Action actionOpen = new AbstractAction("Open...", iconOpen) { public void actionPerformed(ActionEvent e) { System.out.println("open action"); } }; item = mFile.add(actionOpen); mFile.add(item); ImageIcon iconSave = new ImageIcon("file_save.gif"); Action actionSave = new AbstractAction("Save...", iconSave) { public void actionPerformed(ActionEvent e) { System.out.println("save action"); } }; item = mFile.add(actionSave); mFile.add(item); mFile.addSeparator(); Action actionExit = new AbstractAction("Exit") { public void actionPerformed(ActionEvent e) { System.exit(0); } }; item = mFile.add(actionExit); item.setMnemonic('x'); menuBar.add(mFile); toolBar = new JToolBar(); JButton btn1 = toolBar.add(actionNew); btn1.setToolTipText("New text"); JButton btn2 = toolBar.add(actionOpen); btn2.setToolTipText("Open text file"); JButton btn3 = toolBar.add(actionSave); btn3.setToolTipText("Save text file"); ActionListener fontListener = new ActionListener() { public void actionPerformed(ActionEvent e) { updateMonitor(); } }; JMenu mFont = new JMenu("Font"); mFont.setMnemonic('o'); ButtonGroup group = new ButtonGroup(); fontMenus = new JMenuItem[FontNames.length]; for (int k = 0; k < FontNames.length; k++) { int m = k + 1; fontMenus[k] = new JRadioButtonMenuItem(m + " " + FontNames[k]); boolean selected = (k == 0); fontMenus[k].setSelected(selected); fontMenus[k].setMnemonic('1' + k); fontMenus[k].setFont(fonts[k]); fontMenus[k].addActionListener(fontListener); group.add(fontMenus[k]); mFont.add(fontMenus[k]); } mFont.addSeparator(); boldMenu.setMnemonic('b'); Font fn = fonts[1].deriveFont(Font.BOLD); boldMenu.setFont(fn); boldMenu.setSelected(false); boldMenu.addActionListener(fontListener); mFont.add(boldMenu); italicMenu.setMnemonic('i'); fn = fonts[1].deriveFont(Font.ITALIC); italicMenu.setFont(fn); italicMenu.setSelected(false); italicMenu.addActionListener(fontListener); mFont.add(italicMenu); menuBar.add(mFont); getContentPane().add(toolBar, BorderLayout.NORTH); return menuBar; }
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Creates the menu.//ww w .ja va 2 s .c o m */ private void createMenuBar() { // Create the menu bar final JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); // Create the 'File' menu final JMenu fileMenu = I18N.createMenu(menuBar, "file"); fileMenu.add(this.newAction); fileMenu.add(this.openAction); fileMenu.addSeparator(); fileMenu.add(this.closeAction); fileMenu.add(this.closeAllAction); fileMenu.addSeparator(); fileMenu.add(this.saveAction); fileMenu.add(this.saveAsAction); fileMenu.add(this.saveAllAction); fileMenu.addSeparator(); fileMenu.add(this.printAction); fileMenu.addSeparator(); final JMenu exportMenu = I18N.createMenu(fileMenu, "export"); exportMenu.add(this.exportASCIIAction); exportMenu.add(this.exportTemplateCodeAction); final JMenu importMenu = I18N.createMenu(fileMenu, "import"); importMenu.add(this.importTemplateCodeAction); fileMenu.addSeparator(); fileMenu.add(this.exitAction); // Create the 'Edit' menu final JMenu editMenu = I18N.createMenu(menuBar, "edit"); editMenu.add(new CopyAction(this)); editMenu.add(this.selectAllAction); editMenu.addSeparator(); editMenu.add(this.preferencesAction); // Create the 'Complex' menu final JMenu complexMenu = I18N.createMenu(menuBar, "complex"); complexMenu.add(this.addFactoryAction); complexMenu.add(this.changeSectorAction); complexMenu.add(this.changeSunsAction); complexMenu.add(this.changePricesAction); complexMenu.add(new JCheckBoxMenuItem(this.toggleBaseComplexAction)); // Create the 'Help' menu final JMenu helpMenu = I18N.createMenu(menuBar, "help"); helpMenu.add(this.donateAction); helpMenu.addSeparator(); helpMenu.add(this.homepageAction); helpMenu.add(this.forumAction); helpMenu.add(this.twitterAction); helpMenu.add(this.googlePlusAction); helpMenu.add(this.githubAction); helpMenu.addSeparator(); helpMenu.add(this.aboutAction); installStatusHandler(menuBar); }
From source file:com.opendoorlogistics.studio.appframe.AppFrame.java
private void initFileMenu(JMenu mnFile, List<? extends Action> fileActions, ActionFactory actionFactory, MenuFactory menuBuilder) {//from w w w .jav a2 s. c o m mnFile.removeAll(); // non-dynamic for (Action action : fileActions) { if (action == null) { mnFile.addSeparator(); } else { mnFile.add(action); // if (action.accelerator != null) { // item.setAccelerator(action.accelerator); // } } } // import (not in action list as doesn't appear on toolbar) mnFile.addSeparator(); JMenu mnImport = menuBuilder.createImportMenu(this); mnFile.add(mnImport); // dynamic mnFile.addSeparator(); for (AppFrameAction action : actionFactory.createLoadRecentFilesActions(this)) { mnFile.add(action); } // clear recent mnFile.addSeparator(); mnFile.add(new AppFrameAction("Clear recent files", "Clear recent files", null, null, false, null, this) { @Override public void actionPerformed(ActionEvent e) { PreferencesManager.getSingleton().clearRecentFiles(); } }); // finally exit mnFile.addSeparator(); JMenuItem item = mnFile.add(new AppFrameAction("Exit", "Exit", null, null, false, KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.Event.CTRL_MASK), this) { @Override public void actionPerformed(ActionEvent e) { dispose(); System.exit(0); } }); // item.setAccelerator(((AppFrameAction) item.getAction()).accelerator); mnFile.validate(); }
From source file:org.jfree.chart.demo.SuperDemo.java
private JMenuBar createMenuBar() { JMenuBar jmenubar = new JMenuBar(); JMenu jmenu = new JMenu("File", true); jmenu.setMnemonic('F'); JMenuItem jmenuitem = new JMenuItem("Export to PDF...", 112); jmenuitem.setActionCommand("EXPORT_TO_PDF"); jmenuitem.addActionListener(this); jmenu.add(jmenuitem);/*from w ww. ja v a2 s. co m*/ jmenu.addSeparator(); JMenuItem jmenuitem1 = new JMenuItem("Exit", 120); jmenuitem1.setActionCommand("EXIT"); jmenuitem1.addActionListener(this); jmenu.add(jmenuitem1); jmenubar.add(jmenu); return jmenubar; }
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 w ww. j a va 2 s . c o 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; }