List of usage examples for javax.swing JMenu setName
public void setName(String name)
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 . j a v a2s .com 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:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java
/** * Creates the menu bar.// www. j a v a 2 s . c o m */ 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); }
From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ActionComponentManager.java
/** * Gets the menu with name./* ww w . j a va 2 s . c o m*/ * * @param name the name * * @return the menu with name */ private synchronized JMenu getMenuWithName(String name) { // get index of matching menu if exists int menuIndex = getMenuIndex(name); if (menuIndex > -1) { return menuBar.getMenu(menuIndex); } else { logger.info("Menu " + name + " does not exist. Adding to menu bar"); JMenu menu = new JMenu(name); menu.setName(name + "Menu"); menuBar.add(menu); return menu; } }