List of usage examples for javax.swing JMenuItem setName
public void setName(String name)
From source file:processing.app.Editor.java
protected JMenu addInternalTools(JMenu menu) { JMenuItem item; item = createToolMenuItem("cc.arduino.packages.formatter.AStyle"); item.setName("menuToolsAutoFormat"); int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers)); menu.add(item);//from w w w . j ava 2 s .co m //menu.add(createToolMenuItem("processing.app.tools.CreateFont")); //menu.add(createToolMenuItem("processing.app.tools.ColorSelector")); menu.add(createToolMenuItem("processing.app.tools.Archiver")); menu.add(createToolMenuItem("processing.app.tools.FixEncoding")); // // These are temporary entries while Android mode is being worked out. // // The mode will not be in the tools menu, and won't involve a cmd-key // if (!Base.RELEASE) { // item = createToolMenuItem("processing.app.tools.android.AndroidTool"); // item.setAccelerator(KeyStroke.getKeyStroke('D', modifiers)); // menu.add(item); // menu.add(createToolMenuItem("processing.app.tools.android.Reset")); // } return menu; }
From source file:processing.app.Editor.java
protected JMenu buildEditMenu() { JMenu menu = new JMenu(_("Edit")); menu.setName("menuEdit"); undoItem = newJMenuItem(_("Undo"), 'Z'); undoItem.setName("menuEditUndo"); undoItem.addActionListener(undoAction = new UndoAction()); menu.add(undoItem);//from w ww . ja v a 2s. c o m if (!OSUtils.isMacOS()) { redoItem = newJMenuItem(_("Redo"), 'Y'); } else { redoItem = newJMenuItemShift(_("Redo"), 'Z'); } redoItem.setName("menuEditRedo"); redoItem.addActionListener(redoAction = new RedoAction()); menu.add(redoItem); menu.addSeparator(); // TODO "cut" and "copy" should really only be enabled // if some text is currently selected JMenuItem cutItem = newJMenuItem(_("Cut"), 'X'); cutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCut(); } }); menu.add(cutItem); JMenuItem copyItem = newJMenuItem(_("Copy"), 'C'); copyItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.copy(); } }); menu.add(copyItem); JMenuItem copyForumItem = newJMenuItemShift(_("Copy for Forum"), 'C'); copyForumItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // SwingUtilities.invokeLater(new Runnable() { // public void run() { new DiscourseFormat(Editor.this, false).show(); // } // }); } }); menu.add(copyForumItem); JMenuItem copyHTMLItem = newJMenuItemAlt(_("Copy as HTML"), 'C'); copyHTMLItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // SwingUtilities.invokeLater(new Runnable() { // public void run() { new DiscourseFormat(Editor.this, true).show(); // } // }); } }); menu.add(copyHTMLItem); JMenuItem pasteItem = newJMenuItem(_("Paste"), 'V'); pasteItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.paste(); sketch.setModified(true); } }); menu.add(pasteItem); JMenuItem selectAllItem = newJMenuItem(_("Select All"), 'A'); selectAllItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.selectAll(); } }); menu.add(selectAllItem); menu.addSeparator(); JMenuItem commentItem = newJMenuItem(_("Comment/Uncomment"), '/'); commentItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCommentUncomment(); } }); menu.add(commentItem); JMenuItem increaseIndentItem = new JMenuItem(_("Increase Indent")); increaseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); increaseIndentItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); } }); menu.add(increaseIndentItem); JMenuItem decreseIndentItem = new JMenuItem(_("Decrease Indent")); decreseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK)); decreseIndentItem.setName("menuDecreaseIndent"); decreseIndentItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); } }); menu.add(decreseIndentItem); menu.addSeparator(); JMenuItem findItem = newJMenuItem(_("Find..."), 'F'); findItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find == null) { find = new FindReplace(Editor.this); } if (!OSUtils.isMacOS()) { find.setFindText(getSelectedText()); } find.setLocationRelativeTo(Editor.this); find.setVisible(true); } }); menu.add(findItem); JMenuItem findNextItem = newJMenuItem(_("Find Next"), 'G'); findNextItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find != null) { find.findNext(); } } }); menu.add(findNextItem); JMenuItem findPreviousItem = newJMenuItemShift(_("Find Previous"), 'G'); findPreviousItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find != null) { find.findPrevious(); } } }); menu.add(findPreviousItem); if (OSUtils.isMacOS()) { JMenuItem useSelectionForFindItem = newJMenuItem(_("Use Selection For Find"), 'E'); useSelectionForFindItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (find == null) { find = new FindReplace(Editor.this); } find.setFindText(getSelectedText()); } }); menu.add(useSelectionForFindItem); } return menu; }
From source file:processing.app.Editor.java
protected void configurePopupMenu(final SketchTextArea textarea) { JPopupMenu menu = textarea.getPopupMenu(); menu.addSeparator();/*from www . j a v a 2 s. c om*/ JMenuItem item = createToolMenuItem("cc.arduino.packages.formatter.AStyle"); item.setName("menuToolsAutoFormat"); menu.add(item); item = newJMenuItem(_("Comment/Uncomment"), '/'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCommentUncomment(); } }); menu.add(item); item = newJMenuItem(_("Increase Indent"), ']'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); } }); menu.add(item); item = newJMenuItem(_("Decrease Indent"), '['); item.setName("menuDecreaseIndent"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); } }); menu.add(item); item = new JMenuItem(_("Copy for Forum")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleDiscourseCopy(); } }); menu.add(item); item = new JMenuItem(_("Copy as HTML")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleHTMLCopy(); } }); menu.add(item); final JMenuItem referenceItem = new JMenuItem(_("Find in Reference")); referenceItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleFindReference(); } }); menu.add(referenceItem); final JMenuItem openURLItem = new JMenuItem(_("Open URL")); openURLItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL(e.getActionCommand()); } }); menu.add(openURLItem); menu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { String referenceFile = base.getPdeKeywords().getReference(getCurrentKeyword()); referenceItem.setEnabled(referenceFile != null); int offset = textarea.getCaretPosition(); org.fife.ui.rsyntaxtextarea.Token token = RSyntaxUtilities.getTokenAtOffset(textarea, offset); if (token != null && token.isHyperlink()) { openURLItem.setEnabled(true); openURLItem.setActionCommand(token.getLexeme()); } else { openURLItem.setEnabled(false); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); }
From source file:processing.app.EditorTab.java
private void configurePopupMenu(final SketchTextArea textarea) { JPopupMenu menu = textarea.getPopupMenu(); menu.addSeparator();/* www . j a va 2 s.co m*/ JMenuItem item = editor.createToolMenuItem("cc.arduino.packages.formatter.AStyle"); if (item == null) { throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable"); } item.setName("menuToolsAutoFormat"); menu.add(item); item = new JMenuItem(tr("Comment/Uncomment"), '/'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCommentUncomment(); } }); menu.add(item); item = new JMenuItem(tr("Increase Indent"), ']'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); } }); menu.add(item); item = new JMenuItem(tr("Decrease Indent"), '['); item.setName("menuDecreaseIndent"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); } }); menu.add(item); item = new JMenuItem(tr("Copy for Forum")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleDiscourseCopy(); } }); menu.add(item); item = new JMenuItem(tr("Copy as HTML")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleHTMLCopy(); } }); menu.add(item); final JMenuItem referenceItem = new JMenuItem(tr("Find in Reference")); referenceItem.addActionListener(editor::handleFindReference); menu.add(referenceItem); final JMenuItem openURLItem = new JMenuItem(tr("Open URL")); openURLItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Base.openURL(e.getActionCommand()); } }); menu.add(openURLItem); menu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { String referenceFile = editor.base.getPdeKeywords().getReference(getCurrentKeyword()); referenceItem.setEnabled(referenceFile != null); int offset = textarea.getCaretPosition(); org.fife.ui.rsyntaxtextarea.Token token = RSyntaxUtilities.getTokenAtOffset(textarea, offset); if (token != null && token.isHyperlink()) { openURLItem.setEnabled(true); openURLItem.setActionCommand(token.getLexeme()); } else { openURLItem.setEnabled(false); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); }
From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java
/** * Creates the menu bar.//from w ww.j a v a 2 s . com */ protected synchronized void createMenuBar() { menuBar = new JMenuBar(); menuBar.setName("menuBar"); // NOI18N JMenu fileMenu = new JMenu(); JMenuItem exitMenuItem = new JMenuItem(); JSeparator statusPanelSeparator = new JSeparator(); statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N fileMenu.setText("File"); // NOI18N fileMenu.setName("fileMenu"); // NOI18N exitMenuItem.setAction(actionMap.get("quitApp")); // NOI18N exitMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); exitMenuItem.setName("exitMenuItem"); // NOI18N fileMenu.add(exitMenuItem); menuBar.add(fileMenu); // query menu JMenu queryMenu = new JMenu(); queryMenu.setText("Query"); queryMenu.setName("queryMenu"); menuBar.add(queryMenu); // dataMenu JMenu dataMenu = new JMenu(); dataMenu.setText("Data"); dataMenu.setName("dataMenu"); menuBar.add(dataMenu); // toolsMenu JMenu toolsMenu = new JMenu(); toolsMenu.setText("Tools"); toolsMenu.setName("toolsMenu"); menuBar.add(toolsMenu); // view menu JMenu viewMenu = new JMenu(); viewMenu.setText(resourceMap.getString("viewMenu.text")); viewMenu.setName("viewMenu"); viewMenu.add(actionMap.get("saveViewLayout")); viewMenu.add(actionMap.get("restoreViewLayout")); menuBar.add(viewMenu); // help menu JMenu helpMenu = new JMenu(); helpMenu.setText("Help"); // NOI18N helpMenu.setName("helpMenu"); // NOI18N helpMenu.add(actionMap.get("showErrorReportingURL")); helpMenu.add(actionMap.get("showFeatureRequestURL")); helpMenu.add(actionMap.get("showAboutDialog")); menuBar.add(helpMenu); }