List of usage examples for javax.swing JMenu add
public JMenuItem add(Action a)
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
private void setMenuItem(final JMenu menu, final RSyntaxTextArea childDataArea, final String type) { JMenuItem item = new JMenuItem(type); menu.add(item); item.addActionListener(new ActionListener() { @Override// w w w . ja v a 2 s . c o m public void actionPerformed(ActionEvent e) { String content = childDataArea.getText(); childDataArea.setSyntaxEditingStyle(type); childDataArea.setText(content); } }); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private JMenu createFileMenu() { JMenu file_menu = new JMenu("File"); file_menu.add(theActionManager.get("print")); return file_menu; }
From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java
private JMenu buildCategoryMenu() { JMenu categoryMenu = new JMenu("Categories"); categoryMenu.setMnemonic('t'); JMenuItem showItem = new JMenuItem("Show"); showItem.setMnemonic('s'); JMenuItem addCatButton = createAddCatMenuItem(); showItem.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { Focuser.focus(tree, treeModel, treeModel.getCategoriesNode()); }/*from www . ja v a 2s .c o m*/ }); categoryMenu.add(showItem); categoryMenu.addSeparator(); categoryMenu.add(addCatButton); return categoryMenu; }
From source file:InternalFrameTest.java
public DesktopFrame() { setTitle("InternalFrameTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); desktop = new JDesktopPane(); add(desktop, BorderLayout.CENTER); // set up menus JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar);/*from w ww . j av a 2 s.com*/ JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); JMenuItem openItem = new JMenuItem("New"); openItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { createInternalFrame(new JLabel(new ImageIcon(planets[counter] + ".gif")), planets[counter]); counter = (counter + 1) % planets.length; } }); fileMenu.add(openItem); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(exitItem); JMenu windowMenu = new JMenu("Window"); menuBar.add(windowMenu); JMenuItem nextItem = new JMenuItem("Next"); nextItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { selectNextWindow(); } }); windowMenu.add(nextItem); JMenuItem cascadeItem = new JMenuItem("Cascade"); cascadeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { cascadeWindows(); } }); windowMenu.add(cascadeItem); JMenuItem tileItem = new JMenuItem("Tile"); tileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { tileWindows(); } }); windowMenu.add(tileItem); final JCheckBoxMenuItem dragOutlineItem = new JCheckBoxMenuItem("Drag Outline"); dragOutlineItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { desktop.setDragMode(dragOutlineItem.isSelected() ? JDesktopPane.OUTLINE_DRAG_MODE : JDesktopPane.LIVE_DRAG_MODE); } }); windowMenu.add(dragOutlineItem); }
From source file:org.pgptool.gui.ui.mainframe.MainFrameView.java
private void initMenuBar() { menuBar = new JMenuBar(); JMenu menuFile = new JMenu(Messages.get("term.appTitle")); menuFile.add(miChangeTempFolderForDecrypted = new JMenuItem()); menuFile.addSeparator();/*from w ww.j a v a 2 s .c o m*/ menuFile.add(miBmc = new JMenuItem()); menuFile.add(miWriteFeedback = new JMenuItem()); menuFile.add(miFaq = new JMenuItem()); menuFile.add(miHelp = new JMenuItem()); menuFile.addSeparator(); menuFile.add(miAbout = new JMenuItem()); menuFile.add(miCheckForUpdates = new JMenuItem()); menuFile.add(miAutoCheckForUpdates = new JCheckBoxMenuItem()); menuFile.addSeparator(); menuFile.add(miConfigExit = new JMenuItem()); JMenu menuKeyring = new JMenu(Messages.get("term.keyring")); menuKeyring.add(miShowKeyList = new JMenuItem()); menuKeyring.addSeparator(); menuKeyring.add(miPgpImportKey = new JMenuItem()); menuKeyring.add(miPgpCreateKey = new JMenuItem()); JMenu menuActions = new JMenu(Messages.get("term.actions")); menuActions.add(miEncrypt = new JMenuItem()); menuActions.add(miEncryptText = new JMenuItem()); menuActions.addSeparator(); menuActions.add(miDecrypt = new JMenuItem()); menuActions.add(miDecryptText = new JMenuItem()); menuActions.addSeparator(); menuActions.add(miEncryptBackAll = new JMenuItem()); menuBar.add(menuFile); menuBar.add(menuKeyring); menuBar.add(menuActions); }
From source file:net.sf.jabref.gui.RightClickMenu.java
public RightClickMenu(BasePanel panel_, MetaData metaData_) { panel = panel_;//from ww w .j ava2 s.c o m metaData = metaData_; JMenu typeMenu = ChangeEntryTypeMenu.getChangeEntryTypeMenu(panel); // Are multiple entries selected? boolean multiple = panel.mainTable.getSelectedRowCount() > 1; // If only one entry is selected, get a reference to it for adapting the menu. BibEntry be = null; if (panel.mainTable.getSelectedRowCount() == 1) { be = panel.mainTable.getSelected().get(0); } addPopupMenuListener(this); add(new GeneralAction(Actions.COPY, Localization.lang("Copy"), IconTheme.JabRefIcon.COPY.getSmallIcon())); add(new GeneralAction(Actions.PASTE, Localization.lang("Paste"), IconTheme.JabRefIcon.PASTE.getSmallIcon())); add(new GeneralAction(Actions.CUT, Localization.lang("Cut"), IconTheme.JabRefIcon.CUT.getSmallIcon())); add(new GeneralAction(Actions.DELETE, Localization.lang("Delete"), IconTheme.JabRefIcon.DELETE_ENTRY.getSmallIcon())); addSeparator(); add(new GeneralAction(Actions.COPY_KEY, Localization.lang("Copy BibTeX key"))); add(new GeneralAction(Actions.COPY_CITE_KEY, Localization.lang("Copy \\cite{BibTeX key}"))); add(new GeneralAction(Actions.COPY_KEY_AND_TITLE, Localization.lang("Copy BibTeX key and title"))); add(new GeneralAction(Actions.EXPORT_TO_CLIPBOARD, Localization.lang("Export to clipboard"), IconTheme.JabRefIcon.EXPORT_TO_CLIPBOARD.getSmallIcon())); add(new GeneralAction(Actions.SEND_AS_EMAIL, Localization.lang("Send as email"), IconTheme.JabRefIcon.EMAIL.getSmallIcon())); addSeparator(); JMenu markSpecific = JabRefFrame.subMenu("Mark specific color"); JabRefFrame frame = JabRef.jrf; for (int i = 0; i < EntryMarker.MAX_MARKING_LEVEL; i++) { markSpecific.add(new MarkEntriesAction(frame, i).getMenuItem()); } if (multiple) { add(new GeneralAction(Actions.MARK_ENTRIES, Localization.lang("Mark entries"), IconTheme.JabRefIcon.MARK_ENTRIES.getSmallIcon())); add(markSpecific); add(new GeneralAction(Actions.UNMARK_ENTRIES, Localization.lang("Unmark entries"), IconTheme.JabRefIcon.UNMARK_ENTRIES.getSmallIcon())); addSeparator(); } else if (be != null) { String marked = be.getField(BibtexFields.MARKED); // We have to check for "" too as the marked field may be empty if ((marked == null) || marked.isEmpty()) { add(new GeneralAction(Actions.MARK_ENTRIES, Localization.lang("Mark entry"), IconTheme.JabRefIcon.MARK_ENTRIES.getSmallIcon())); add(markSpecific); } else { add(markSpecific); add(new GeneralAction(Actions.UNMARK_ENTRIES, Localization.lang("Unmark entry"), IconTheme.JabRefIcon.UNMARK_ENTRIES.getSmallIcon())); } addSeparator(); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) { if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) { JMenu rankingMenu = new JMenu(); RightClickMenu.populateSpecialFieldMenu(rankingMenu, Rank.getInstance(), JabRef.jrf); add(rankingMenu); } // TODO: multiple handling for relevance and quality-assurance // if multiple values are selected ("if (multiple)"), two options (set / clear) should be offered // if one value is selected either set or clear should be offered if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) { add(Relevance.getInstance().getValues().get(0).getMenuAction(JabRef.jrf)); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) { add(Quality.getInstance().getValues().get(0).getMenuAction(JabRef.jrf)); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) { add(Printed.getInstance().getValues().get(0).getMenuAction(JabRef.jrf)); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) { JMenu priorityMenu = new JMenu(); RightClickMenu.populateSpecialFieldMenu(priorityMenu, Priority.getInstance(), JabRef.jrf); add(priorityMenu); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) { JMenu readStatusMenu = new JMenu(); RightClickMenu.populateSpecialFieldMenu(readStatusMenu, ReadStatus.getInstance(), JabRef.jrf); add(readStatusMenu); } addSeparator(); } add(new GeneralAction(Actions.OPEN_FOLDER, Localization.lang("Open folder")) { { if (!isFieldSetForSelectedEntry("file")) { this.setEnabled(false); } } }); add(new GeneralAction(Actions.OPEN_EXTERNAL_FILE, Localization.lang("Open file"), getFileIconForSelectedEntry()) { { if (!isFieldSetForSelectedEntry("file")) { this.setEnabled(false); } } }); add(new GeneralAction(Actions.ADD_FILE_LINK, Localization.lang("Attach file"), IconTheme.JabRefIcon.ATTACH_FILE.getSmallIcon())); add(new GeneralAction(Actions.OPEN_URL, Localization.lang("Open URL or DOI"), IconTheme.JabRefIcon.WWW.getSmallIcon()) { { if (!(isFieldSetForSelectedEntry("url") || isFieldSetForSelectedEntry("doi"))) { this.setEnabled(false); } } }); add(new GeneralAction(Actions.MERGE_DOI, Localization.lang("Get BibTeX data from DOI")) { { if (!(isFieldSetForSelectedEntry("doi"))) { this.setEnabled(false); } } }); addSeparator(); add(typeMenu); add(new GeneralAction(Actions.PLAIN_TEXT_IMPORT, Localization.lang("Plain text import"))); add(JabRef.jrf.massSetField); add(JabRef.jrf.manageKeywords); addSeparator(); // for "add/move/remove to/from group" entries (appended here) groupAdd = new JMenuItem(new GeneralAction(Actions.ADD_TO_GROUP, Localization.lang("Add to group"))); add(groupAdd); groupRemove = new JMenuItem( new GeneralAction(Actions.REMOVE_FROM_GROUP, Localization.lang("Remove from group"))); add(groupRemove); JMenuItem groupMoveTo = add(new GeneralAction(Actions.MOVE_TO_GROUP, Localization.lang("Move to group"))); add(groupMoveTo); floatMarked.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Globals.prefs.putBoolean(JabRefPreferences.FLOAT_MARKED_ENTRIES, floatMarked.isSelected()); panel.mainTable.refreshSorting(); // Bad remote access } }); // create disabledIcons for all menu entries frame.createDisabledIconsForMenuEntries(this); }
From source file:com.apatar.ui.Actions.java
private void createMenubar() { menubar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(newPrj); fileMenu.add(open);//from www .ja va 2 s .c om fileMenu.addSeparator(); fileMenu.add(save); fileMenu.add(saveAs); fileMenu.addSeparator(); // fileMenu.add(publishToApatar);@@ // fileMenu.add(runScheduling);@@ // fileMenu.addSeparator();@@ fileMenu.add(run); // fileMenu.addSeparator(); // apon // fileMenu.add(newWebService);@@ // fileMenu.addSeparator();@@ // fileMenu.add(options);@@ // fileMenu.addSeparator();@@ fileMenu.add(exit); // JMenu viewMenu = new JMenu("View");//@@ // viewMenu.add(windowsLookAndFeel);//@@ // viewMenu.add(metalLookAndFeel); //@@ // viewMenu.add(motifLookAndFeel); //@@ // JMenu debugMenu = new JMenu("Debug");//@@ // debugMenu.add(debugOutput);//@@ // debugMenu.add(errorOutput);//@@ // JMenu communityMenu = new JMenu("Community");//@@ // communityMenu.add(catalogOfApatars);//@@ // communityMenu.add(demos);//@@ // communityMenu.add(forums);//@@ // communityMenu.add(wiki);//@@ /* * @@ JMenu helpMenu = new JMenu("Help"); helpMenu.add(about); * helpMenu.addSeparator(); helpMenu.add(featureRequest); * helpMenu.add(submitBug); helpMenu.add(tutorials); */ menubar.add(fileMenu); // menubar.add(viewMenu);//@@ // menubar.add(debugMenu);//@@ // menubar.add(communityMenu);//@@ // menubar.add(helpMenu);//@@ }
From source file:edu.harvard.mcz.imagecapture.BulkMediaFrame.java
private void init() { thisFrame = this; setTitle("BulkMedia Preparation"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 902, 174);/*from ww w . j a va2 s .co m*/ JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic(KeyEvent.VK_F); menuBar.add(mnFile); JMenuItem mntmPrepareDirectory = new JMenuItem("Prepare Directory"); mntmPrepareDirectory.setMnemonic(KeyEvent.VK_D); mntmPrepareDirectory.addActionListener(new PrepareDirectoryAction()); mnFile.add(mntmPrepareDirectory); JMenuItem mntmNewMenuItem = new JMenuItem("Exit"); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); JMenuItem mntmNewMenuItem_1 = new JMenuItem("Edit Properties"); mntmNewMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PropertiesEditor p = new PropertiesEditor(); p.pack(); p.setVisible(true); } }); mnFile.add(mntmNewMenuItem_1); mntmNewMenuItem.setMnemonic(KeyEvent.VK_X); mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); mnFile.add(mntmNewMenuItem); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(3, 2, 0, 0)); JLabel lblBaseUri = new JLabel("Base URI (first part of path to images on the web)"); lblBaseUri.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblBaseUri, "2, 2"); textField = new JTextField(); textField.setEditable(false); textField.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASEURI)); panel.add(textField); textField.setColumns(10); JLabel lblNewLabel = new JLabel("Local Path To Base (local mount path that maps to base URI)"); lblNewLabel.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblNewLabel); textField_1 = new JTextField(); textField_1.setEditable(false); textField_1.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASE)); panel.add(textField_1); textField_1.setColumns(10); JLabel lblBeforeExitingWait = new JLabel( "Before exiting wait for both the Done and Thumbnails Built messages."); panel.add(lblBeforeExitingWait); JLabel lblThumbnailGenerationIs = new JLabel("Thumbnail generation is not reported on the progress bar."); panel.add(lblThumbnailGenerationIs); progressBar = new JProgressBar(); progressBar.setStringPainted(false); contentPane.add(progressBar, BorderLayout.NORTH); JPanel panel_1 = new JPanel(); contentPane.add(panel_1, BorderLayout.SOUTH); JButton btnPrepareDirectory = new JButton("Run"); btnPrepareDirectory.setToolTipText("Select a directory and prepare a bulk media file for images therein."); panel_1.add(btnPrepareDirectory); btnPrepareDirectory.addActionListener(new PrepareDirectoryAction()); btnPrepareDirectory.setPreferredSize(new Dimension(80, 25)); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); panel_1.add(btnExit); }
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); fileMenu.add(printItem);//from w w w.j a va2 s .c o m fileMenu.add(new JSeparator()); fileMenu.add(quitItem); menuBar.add(fileMenu); return menuBar; }
From source file:net.sf.jabref.gui.RightClickMenu.java
/** * @param move For add: if true, remove from previous groups *///from w w w . j a v a2 s . c o m private void insertNodes(JMenu menu, GroupTreeNode node, BibEntry[] selection, boolean add, boolean move) { final AbstractAction action = getAction(node, selection, add, move); if (node.getChildCount() == 0) { JMenuItem menuItem = new JMenuItem(action); setGroupFontAndIcon(menuItem, node.getGroup()); menu.add(menuItem); if (action.isEnabled()) { menu.setEnabled(true); } return; } JMenu submenu; if (node.getGroup() instanceof AllEntriesGroup) { for (int i = 0; i < node.getChildCount(); ++i) { insertNodes(menu, (GroupTreeNode) node.getChildAt(i), selection, add, move); } } else { submenu = new JMenu('[' + node.getGroup().getName() + ']'); setGroupFontAndIcon(submenu, node.getGroup()); // setEnabled(true) is done above/below if at least one menu // entry (item or submenu) is enabled submenu.setEnabled(action.isEnabled()); JMenuItem menuItem = new JMenuItem(action); setGroupFontAndIcon(menuItem, node.getGroup()); submenu.add(menuItem); submenu.add(new Separator()); for (int i = 0; i < node.getChildCount(); ++i) { insertNodes(submenu, (GroupTreeNode) node.getChildAt(i), selection, add, move); } menu.add(submenu); if (submenu.isEnabled()) { menu.setEnabled(true); } } }