List of usage examples for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem
public JRadioButtonMenuItem(Action a)
Action
supplied. From source file:edu.ku.brc.ui.UIHelper.java
/** * Creates a JRadioButtonMenuItem.//from w w w . jav a2s .c o m * @param menu parent menu * @param label the label of the menu item * @param mnemonic the mnemonic * @param accessibleDescription the accessible Description * @param enabled enabled * @param action the aciton * @return menu item */ public static JRadioButtonMenuItem createRadioButtonMenuItem(final JMenu menu, final String label, final String mnemonic, final String accessibleDescription, final boolean enabled, final AbstractAction action) { JRadioButtonMenuItem mi = new JRadioButtonMenuItem(getResourceString(label)); if (menu != null) { menu.add(mi); } setLocalizedMnemonic(mi, mnemonic); if (isNotEmpty(accessibleDescription)) { mi.getAccessibleContext().setAccessibleDescription(accessibleDescription); } if (action != null) { mi.addActionListener(action); action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi)); action.setEnabled(enabled); } return mi; }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void makeDefaultXsdMenuItems() { ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem jRadioButtonMenuItem; for (Xsd_enum xsdEnum : Xsd_enum.values()) { jRadioButtonMenuItem = new JRadioButtonMenuItem(xsdEnum.getReadableName()); if (xsdEnum.getReadableName().equals(retrieveFromDb.retrieveDefaultXsd())) { jRadioButtonMenuItem.setSelected(true); }/*from w w w . jav a 2 s . co m*/ jRadioButtonMenuItem.addActionListener(new XsdSelectActionListener()); group.add(jRadioButtonMenuItem); defaultXsdSelectionSubmenu.add(jRadioButtonMenuItem); } for (XsdObject additionalXsd : retrieveFromDb.retrieveAdditionalXsds()) { jRadioButtonMenuItem = new JRadioButtonMenuItem(additionalXsd.getName()); if (additionalXsd.getName().equals(retrieveFromDb.retrieveDefaultXsd())) { jRadioButtonMenuItem.setSelected(true); } jRadioButtonMenuItem.addActionListener(new XsdSelectActionListener()); group.add(jRadioButtonMenuItem); defaultXsdSelectionSubmenu.add(jRadioButtonMenuItem); } }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void makeDefaultXslMenuItems() { ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem jRadioButtonMenuItem; for (File xsltFile : Utilities.getXsltFiles()) { jRadioButtonMenuItem = new JRadioButtonMenuItem(xsltFile.getName()); if (xsltFile.getName().equals(retrieveFromDb.retrieveDefaultXsl())) { jRadioButtonMenuItem.setSelected(true); }/*from w w w. j a va2 s .c om*/ jRadioButtonMenuItem.addActionListener(new XslSelectActionListener()); group.add(jRadioButtonMenuItem); defaultXslSelectionSubmenu.add(jRadioButtonMenuItem); } }
From source file:net.sf.jabref.gui.JabRefFrame.java
private void fillMenu() { mb.setBorder(null);//from ww w . ja v a2 s. c o m JMenu file = JabRefFrame.subMenu(Localization.menuTitle("File")); JMenu edit = JabRefFrame.subMenu(Localization.menuTitle("Edit")); JMenu search = JabRefFrame.subMenu(Localization.menuTitle("Search")); JMenu groups = JabRefFrame.subMenu(Localization.menuTitle("Groups")); JMenu bibtex = JabRefFrame.subMenu("&BibTeX"); JMenu quality = JabRefFrame.subMenu(Localization.menuTitle("Quality")); JMenu view = JabRefFrame.subMenu(Localization.menuTitle("View")); JMenu tools = JabRefFrame.subMenu(Localization.menuTitle("Tools")); JMenu options = JabRefFrame.subMenu(Localization.menuTitle("Options")); JMenu newSpec = JabRefFrame.subMenu(Localization.menuTitle("New entry by type...")); JMenu helpMenu = JabRefFrame.subMenu(Localization.menuTitle("Help")); file.add(newBibtexDatabaseAction); file.add(newBiblatexDatabaseAction); file.add(getOpenDatabaseAction()); file.add(mergeDatabaseAction); file.add(save); file.add(saveAs); file.add(saveAll); file.add(saveSelectedAs); file.add(saveSelectedAsPlain); file.addSeparator(); file.add(importNew); file.add(importCurrent); file.add(exportAll); file.add(exportSelected); file.addSeparator(); file.add(dbConnect); file.add(dbImport); file.add(dbExport); file.addSeparator(); file.add(databaseProperties); file.add(editModeAction); file.addSeparator(); file.add(fileHistory); file.addSeparator(); file.add(closeDatabaseAction); file.add(quit); mb.add(file); edit.add(undo); edit.add(redo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(copyKey); edit.add(copyCiteKey); edit.add(copyKeyAndTitle); edit.add(exportToClipboard); edit.add(sendAsEmail); edit.addSeparator(); edit.add(mark); JMenu markSpecific = JabRefFrame.subMenu(Localization.menuTitle("Mark specific color")); for (int i = 0; i < EntryMarker.MAX_MARKING_LEVEL; i++) { markSpecific.add(new MarkEntriesAction(this, i).getMenuItem()); } edit.add(markSpecific); edit.add(unmark); edit.add(unmarkAll); edit.addSeparator(); if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) { JMenu m; if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) { m = new JMenu(); RightClickMenu.populateSpecialFieldMenu(m, Rank.getInstance(), this); edit.add(m); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) { edit.add(toggleRelevance); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) { edit.add(toggleQualityAssured); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) { m = new JMenu(); RightClickMenu.populateSpecialFieldMenu(m, Priority.getInstance(), this); edit.add(m); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) { edit.add(togglePrinted); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) { m = new JMenu(); RightClickMenu.populateSpecialFieldMenu(m, ReadStatus.getInstance(), this); edit.add(m); } edit.addSeparator(); } edit.add(getManageKeywords()); edit.add(getMassSetField()); edit.addSeparator(); edit.add(selectAll); mb.add(edit); search.add(normalSearch); search.add(replaceAll); search.addSeparator(); search.add(new JCheckBoxMenuItem(generalFetcher.getAction())); if (prefs.getBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE)) { sidePaneManager.register(generalFetcher.getTitle(), generalFetcher); sidePaneManager.show(generalFetcher.getTitle()); } mb.add(search); groups.add(new JCheckBoxMenuItem(toggleGroups)); groups.addSeparator(); groups.add(addToGroup); groups.add(removeFromGroup); groups.add(moveToGroup); groups.addSeparator(); JRadioButtonMenuItem toggleHighlightAnyItem = new JRadioButtonMenuItem(toggleHighlightAny); groups.add(toggleHighlightAnyItem); JRadioButtonMenuItem toggleHighlightAllItem = new JRadioButtonMenuItem(toggleHighlightAll); groups.add(toggleHighlightAllItem); JRadioButtonMenuItem toggleHighlightDisableItem = new JRadioButtonMenuItem(toggleHighlightDisable); groups.add(toggleHighlightDisableItem); ButtonGroup highlightButtonGroup = new ButtonGroup(); highlightButtonGroup.add(toggleHighlightDisableItem); highlightButtonGroup.add(toggleHighlightAnyItem); highlightButtonGroup.add(toggleHighlightAllItem); HighlightMatchingGroupPreferences highlightMatchingGroupPreferences = new HighlightMatchingGroupPreferences( Globals.prefs); if (highlightMatchingGroupPreferences.isAll()) { toggleHighlightAllItem.setSelected(true); } else if (highlightMatchingGroupPreferences.isAny()) { toggleHighlightAnyItem.setSelected(true); } else { toggleHighlightDisableItem.setSelected(true); } mb.add(groups); view.add(getBackAction()); view.add(getForwardAction()); view.add(focusTable); view.add(nextTab); view.add(prevTab); view.add(sortTabs); view.addSeparator(); view.add(increaseFontSize); view.add(decreseFontSize); view.addSeparator(); view.add(new JCheckBoxMenuItem(toggleToolbar)); view.add(new JCheckBoxMenuItem(enableToggle(generalFetcher.getAction()))); view.add(new JCheckBoxMenuItem(toggleGroups)); view.add(new JCheckBoxMenuItem(togglePreview)); view.add(getSwitchPreviewAction()); mb.add(view); bibtex.add(newEntryAction); for (NewEntryAction a : newSpecificEntryAction) { newSpec.add(a); } bibtex.add(newSpec); bibtex.add(plainTextImport); bibtex.addSeparator(); bibtex.add(editEntry); bibtex.add(editPreamble); bibtex.add(editStrings); bibtex.addSeparator(); bibtex.add(customizeAction); bibtex.addSeparator(); bibtex.add(deleteEntry); mb.add(bibtex); quality.add(dupliCheck); quality.add(mergeEntries); quality.addSeparator(); quality.add(resolveDuplicateKeys); quality.add(checkIntegrity); quality.add(cleanupEntries); quality.add(makeKeyAction); quality.addSeparator(); quality.add(autoSetFile); quality.add(findUnlinkedFiles); quality.add(autoLinkFile); quality.add(downloadFullText); mb.add(quality); tools.add(newSubDatabaseAction); tools.add(writeXmpAction); OpenOfficePanel otp = OpenOfficePanel.getInstance(); otp.init(this, sidePaneManager); tools.add(otp.getMenuItem()); tools.add(pushExternalButton.getMenuAction()); tools.addSeparator(); tools.add(openFolder); tools.add(openFile); tools.add(openUrl); tools.add(openConsole); tools.addSeparator(); tools.add(abbreviateIso); tools.add(abbreviateMedline); tools.add(unabbreviate); mb.add(tools); options.add(showPrefs); AbstractAction genFieldsCustomization = new GenFieldsCustomizationAction(); options.add(genFieldsCustomization); options.add(customExpAction); options.add(customImpAction); options.add(customFileTypesAction); options.add(manageJournals); options.add(manageSelectors); options.add(selectKeys); mb.add(options); helpMenu.add(help); helpMenu.add(openForumAction); helpMenu.addSeparator(); helpMenu.add(errorConsole); helpMenu.addSeparator(); helpMenu.add(forkMeOnGitHubAction); helpMenu.add(donationAction); helpMenu.addSeparator(); helpMenu.add(new SearchForUpdateAction()); helpMenu.add(about); mb.add(helpMenu); createDisabledIconsForMenuEntries(mb); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
public void updateMenuBar() { JMenu menu, subMenu;/* w ww.ja va 2 s . c o m*/ ButtonGroup group; int i; if (settingsPane != null) { buttonAdjustMachineSize.setEnabled(!isrunning); buttonAdjustPulleySize.setEnabled(!isrunning); buttonJogMotors .setEnabled(connectionToRobot != null && connectionToRobot.isRobotConfirmed() && !isrunning); buttonChangeTool.setEnabled(!isrunning); buttonAdjustTool.setEnabled(!isrunning); } if (preparePane != null) { buttonHilbertCurve.setEnabled(!isrunning); buttonText2GCODE.setEnabled(!isrunning); } if (driveControls != null) { boolean x = connectionToRobot != null && connectionToRobot.isRobotConfirmed(); driveControls.updateButtonAccess(x, isrunning); } menuBar.removeAll(); // File menu menu = new JMenu(translator.get("MenuMakelangelo")); menu.setMnemonic(KeyEvent.VK_F); menuBar.add(menu); subMenu = new JMenu(translator.get("MenuPreferences")); buttonAdjustSounds = new JMenuItem(translator.get("MenuSoundsTitle")); buttonAdjustSounds.addActionListener(this); subMenu.add(buttonAdjustSounds); buttonAdjustGraphics = new JMenuItem(translator.get("MenuGraphicsTitle")); buttonAdjustGraphics.addActionListener(this); subMenu.add(buttonAdjustGraphics); buttonAdjustLanguage = new JMenuItem(translator.get("MenuLanguageTitle")); buttonAdjustLanguage.addActionListener(this); subMenu.add(buttonAdjustLanguage); menu.add(subMenu); buttonCheckForUpdate = new JMenuItem(translator.get("MenuUpdate"), KeyEvent.VK_U); buttonCheckForUpdate.addActionListener(this); buttonCheckForUpdate.setEnabled(true); menu.add(buttonCheckForUpdate); buttonAbout = new JMenuItem(translator.get("MenuAbout"), KeyEvent.VK_A); buttonAbout.addActionListener(this); menu.add(buttonAbout); menu.addSeparator(); buttonExit = new JMenuItem(translator.get("MenuQuit"), KeyEvent.VK_Q); buttonExit.addActionListener(this); menu.add(buttonExit); // Connect menu subMenu = new JMenu(translator.get("MenuConnect")); subMenu.setEnabled(!isrunning); group = new ButtonGroup(); String[] connections = connectionManager.listConnections(); buttonPorts = new JRadioButtonMenuItem[connections.length]; for (i = 0; i < connections.length; ++i) { buttonPorts[i] = new JRadioButtonMenuItem(connections[i]); if (connectionToRobot != null && connectionToRobot.getRecentConnection().equals(connections[i]) && connectionToRobot.isConnectionOpen()) { buttonPorts[i].setSelected(true); } buttonPorts[i].addActionListener(this); group.add(buttonPorts[i]); subMenu.add(buttonPorts[i]); } subMenu.addSeparator(); buttonRescan = new JMenuItem(translator.get("MenuRescan"), KeyEvent.VK_N); buttonRescan.addActionListener(this); subMenu.add(buttonRescan); buttonDisconnect = new JMenuItem(translator.get("MenuDisconnect"), KeyEvent.VK_D); buttonDisconnect.addActionListener(this); buttonDisconnect.setEnabled(connectionToRobot != null && connectionToRobot.isConnectionOpen()); subMenu.add(buttonDisconnect); menuBar.add(subMenu); // view menu menu = new JMenu(translator.get("MenuPreview")); buttonZoomOut = new JMenuItem(translator.get("ZoomOut")); buttonZoomOut.addActionListener(this); buttonZoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, ActionEvent.ALT_MASK)); menu.add(buttonZoomOut); buttonZoomIn = new JMenuItem(translator.get("ZoomIn"), KeyEvent.VK_EQUALS); buttonZoomIn.addActionListener(this); buttonZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ActionEvent.ALT_MASK)); menu.add(buttonZoomIn); buttonZoomToFit = new JMenuItem(translator.get("ZoomFit")); buttonZoomToFit.addActionListener(this); menu.add(buttonZoomToFit); menuBar.add(menu); // finish menuBar.updateUI(); }
From source file:net.sourceforge.pmd.util.designer.Designer.java
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Language"); ButtonGroup group = new ButtonGroup(); LanguageVersion[] languageVersions = getSupportedLanguageVersions(); for (int i = 0; i < languageVersions.length; i++) { LanguageVersion languageVersion = languageVersions[i]; JRadioButtonMenuItem button = new JRadioButtonMenuItem(languageVersion.getShortName()); languageVersionMenuItems[i] = button; group.add(button);// w w w . ja v a 2s . c o m menu.add(button); } languageVersionMenuItems[getDefaultLanguageVersionSelectionIndex()].setSelected(true); menuBar.add(menu); JMenu actionsMenu = new JMenu("Actions"); JMenuItem copyXMLItem = new JMenuItem("Copy xml to clipboard"); copyXMLItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copyXmlToClipboard(); } }); actionsMenu.add(copyXMLItem); JMenuItem createRuleXMLItem = new JMenuItem("Create rule XML"); createRuleXMLItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createRuleXML(); } }); actionsMenu.add(createRuleXMLItem); menuBar.add(actionsMenu); return menuBar; }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
/** * initialize LayoutMenu/*from w w w. ja va 2s . c o m*/ * * @return */ private JMenu getLayoutMenu() { if (layoutMenu == null) { layoutMenu = new JMenu(); final JRadioButtonMenuItem frButton = new JRadioButtonMenuItem(LayoutType.FRLayout.toString()); final JRadioButtonMenuItem ewButton = new JRadioButtonMenuItem(LayoutType.EWLayout.toString()); ItemListener layoutMenuItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem().equals(frButton)) { setLayout(LayoutType.FRLayout); layoutBox.setSelectedItem(LayoutType.FRLayout); } else if (e.getItem().equals(ewButton)) { setLayout(LayoutType.EWLayout); layoutBox.setSelectedItem(LayoutType.EWLayout); } } } }; frButton.addItemListener(layoutMenuItemListener); ewButton.addItemListener(layoutMenuItemListener); ButtonGroup radio = new ButtonGroup(); radio.add(frButton); radio.add(ewButton); frButton.setSelected(true); layoutMenu.add(frButton); layoutMenu.add(ewButton); layoutMenu.setToolTipText("Menu for setting graph layout"); // layoutMenu.addItemListener(layoutMenuItemListener); layoutBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem().equals(LayoutType.FRLayout)) { frButton.setSelected(true); } else if (e.getItem().equals(LayoutType.EWLayout)) { ewButton.setSelected(true); } } } }); } return layoutMenu; }
From source file:org.broad.igv.track.TrackMenuUtils.java
public static void addDisplayModeItems(final Collection<Track> tracks, JPopupMenu menu) { // Find "most representative" state from track collection Map<Track.DisplayMode, Integer> counts = new HashMap<Track.DisplayMode, Integer>( Track.DisplayMode.values().length); Track.DisplayMode currentMode = null; for (Track t : tracks) { Track.DisplayMode mode = t.getDisplayMode(); if (counts.containsKey(mode)) { counts.put(mode, counts.get(mode) + 1); } else {// w ww .j a va 2 s .co m counts.put(mode, 1); } } int maxCount = -1; for (Map.Entry<Track.DisplayMode, Integer> count : counts.entrySet()) { if (count.getValue() > maxCount) { currentMode = count.getKey(); maxCount = count.getValue(); } } ButtonGroup group = new ButtonGroup(); Map<String, Track.DisplayMode> modes = new LinkedHashMap<String, Track.DisplayMode>(4); modes.put("Collapsed", Track.DisplayMode.COLLAPSED); modes.put("Expanded", Track.DisplayMode.EXPANDED); modes.put("Squished", Track.DisplayMode.SQUISHED); boolean showAS = Boolean.parseBoolean(System.getProperty("showAS", "false")); if (showAS) { modes.put("Alternative Splice", Track.DisplayMode.ALTERNATIVE_SPLICE); } for (final Map.Entry<String, Track.DisplayMode> entry : modes.entrySet()) { JRadioButtonMenuItem mm = new JRadioButtonMenuItem(entry.getKey()); mm.setSelected(currentMode == entry.getValue()); mm.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { setTrackDisplayMode(tracks, entry.getValue()); refresh(); } }); group.add(mm); menu.add(mm); } }
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
/** * Instances and shows Puck's main frame. *//*from ww w .j av a 2 s. c o m*/ public PuckFrame() { super(); setLookAndFeel(PuckConfiguration.getInstance().getProperty("look")); /* LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for ( int i = 0 ; i < lfs.length ; i++ ) { if ( lfs[i].getName().toLowerCase().contains("nimbus") ) { try { UIManager.setLookAndFeel(lfs[i].getClassName()); } catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen) { e.printStackTrace(); } } } */ setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"), PuckConfiguration.getInstance().getIntegerProperty("windowHeight")); setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"), PuckConfiguration.getInstance().getIntegerProperty("windowLocationY")); //setSize(600,600); if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized")) maximizeIfPossible(); //setTitle(Messages.getInstance().getMessage("frame.title")); refreshTitle(); left = new JPanel(); right = new JPanel(); JScrollPane rightScroll = new JScrollPane(right); rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!) split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) { //dynamic resizing of right panel /* public void setDividerLocation ( int pixels ) { if ( propPanel != null ) { double rightPartSize = getContentPane().getWidth() - pixels - 15; System.out.println("rps=" + rightPartSize); System.out.println("mnw=" + this.getMinimumSize().getWidth()); Dimension propPanSize = propPanel.getSize(); int propPanHeight = 0; if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight(); //propPanel.revalidate(); System.out.println("h " + propPanHeight); //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() ) propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight)); propPanel.revalidate(); } super.setDividerLocation(pixels); } */ }; split.setContinuousLayout(true); split.setResizeWeight(0.60); final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0); /* SwingUtilities.invokeLater(new Runnable(){ public void run() { */ /* } }); */ split.setOneTouchExpandable(true); getContentPane().add(split); System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20)); //it's 32x32. Will have to do it. //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") ); //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png"); left.setLayout(new BorderLayout()); //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS)); if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing")) right.setLayout(new BorderLayout()); else right.setLayout(new FlowLayout()); propPanel = new PropertiesPanel(); right.add(propPanel); graphPanel = new GraphEditingPanel(propPanel); graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); graphPanel.setSnapToGrid( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); propPanel.setGraphEditingPanel(graphPanel); tools = new PuckToolBar(graphPanel, propPanel, this); left.add(tools, BorderLayout.WEST); left.add(graphPanel, BorderLayout.CENTER); /* Action testAction = new AbstractAction() { public void actionPerformed ( ActionEvent evt ) { System.out.println("Puck!"); } } ; testAction.putValue(Action.NAME,"Print Puck"); tools.add(testAction); */ /* public void saveChanges ( ) { if ( editingFileName == null ) { //save as... code } else { File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } } */ JMenuBar mainMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file")); fileMenu.setMnemonic(KeyEvent.VK_F); saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save")); saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (editingFileName == null) JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!", JOptionPane.ERROR_MESSAGE); /* File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } */ try { saveChangesInCurrentFile(); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }); JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new")); JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank")); //newBlankMenuItem.setMnemonic(KeyEvent.VK_N); newBlankMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GraphElementPanel.emptyQueue(); //stop deferred loads graphPanel.clear(); propPanel.clear(); JSyntaxBSHCodeFrame.closeAllInstances(); WorldPanel wp = new WorldPanel(graphPanel); WorldNode wn = new WorldNode(wp); graphPanel.setWorldNode(wn); propPanel.show(graphPanel.getWorldNode()); resetCurrentlyEditingFile(); refreshTitle(); //revalidate(); //only since java 1.7 //invalidate(); //validate(); split.revalidate(); //JComponents do have it before java 1.7 (not JFrame) } }); newMenu.add(newBlankMenuItem); JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu(); if (templateMenus != null) { for (int i = 0; i < templateMenus.getItemCount(); i++) { if (i == 0) newMenu.add(new JSeparator()); newMenu.add(templateMenus.getItem(i)); } } JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas")); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* JFileChooser jfc = new JFileChooser("."); int opt = jfc.showSaveDialog(PuckFrame.this); if ( opt == JFileChooser.APPROVE_OPTION ) { File f = jfc.getSelectedFile(); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); saveMenuItem.setEnabled(true); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } */ try { saveAs(); saveMenuItem.setEnabled(true); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } //saveAs(saveMenuItem); } }); JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open")); openMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //graphPanel.setVisible(false); //propPanel.setVisible(false); JFileChooser jfc = new JFileChooser("."); jfc.setFileFilter(new FiltroFicheroMundo()); int opt = jfc.showOpenDialog(PuckFrame.this); if (opt == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); openFileOrShowError(f); } //graphPanel.setVisible(true); //propPanel.setVisible(true); } }); openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent")); JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit")); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if ( opt == JOptionPane.YES_OPTION ) System.exit(0); */ userExit(); } }); JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export")); JMenuItem exportAppletMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.file.export.applet")); exportAppletMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this); dial.setVisible(true); } }); exportMenu.add(exportAppletMenuItem); fileMenu.add(newMenu); fileMenu.add(openMenuItem); fileMenu.add(openRecentMenu); updateRecentMenu(); fileMenu.add(new JSeparator()); saveMenuItem.setEnabled(false); fileMenu.add(saveMenuItem); fileMenu.add(saveAsMenuItem); fileMenu.add(exportMenu); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); mainMenuBar.add(fileMenu); /** * Create an Edit menu to support cut/copy/paste. */ JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit")); editMenu.setMnemonic(KeyEvent.VK_E); JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity")); findMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showFindEntityDialog(); } }); editMenu.add(findMenuItem); editMenu.add(new JSeparator()); JMenuItem aMenuItem = new JMenuItem(new CutAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut")); aMenuItem.setMnemonic(KeyEvent.VK_T); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new CopyAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy")); aMenuItem.setMnemonic(KeyEvent.VK_C); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new PasteAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste")); aMenuItem.setMnemonic(KeyEvent.VK_P); editMenu.add(aMenuItem); mainMenuBar.add(editMenu); JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options")); JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid")); optionsMenu.add(gridMenu); final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.show")); showGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); gridMenu.add(showGridItem); showGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setGrid(true); PuckConfiguration.getInstance().setProperty("showGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setGrid(false); PuckConfiguration.getInstance().setProperty("showGrid", "false"); } graphPanel.repaint(); } }); final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.snap")); snapToGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); gridMenu.add(snapToGridItem); snapToGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setSnapToGrid(true); PuckConfiguration.getInstance().setProperty("snapToGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setSnapToGrid(false); PuckConfiguration.getInstance().setProperty("snapToGrid", "false"); } graphPanel.repaint(); } }); JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation")); ButtonGroup translationGroup = new ButtonGroup(); final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.hold")); final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.push")); pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode"))); if (!pushMenuItem.isSelected()) holdMenuItem.setSelected(true); translationGroup.add(holdMenuItem); translationGroup.add(pushMenuItem); holdMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (holdMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("translateMode", "hold"); else PuckConfiguration.getInstance().setProperty("translateMode", "push"); } }); translationModeMenu.add(holdMenuItem); translationModeMenu.add(pushMenuItem); optionsMenu.add(translationModeMenu); JMenuItem toolSelectionModeMenu = new JMenu( UIMessages.getInstance().getMessage("menu.options.toolselection")); ButtonGroup toolSelectionGroup = new ButtonGroup(); final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse")); final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse")); multipleUseMenuItem.setSelected( "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode"))); if (!multipleUseMenuItem.isSelected()) oneUseMenuItem.setSelected(true); toolSelectionGroup.add(oneUseMenuItem); toolSelectionGroup.add(multipleUseMenuItem); oneUseMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (oneUseMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse"); else PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse"); } }); toolSelectionModeMenu.add(oneUseMenuItem); toolSelectionModeMenu.add(multipleUseMenuItem); optionsMenu.add(toolSelectionModeMenu); JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes")); sizesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(sizesMenuItem); JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide")); showHideMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(showHideMenuItem); JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors")); mapColorsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(mapColorsMenuItem); String skinList = PuckConfiguration.getInstance().getProperty("availableSkins"); if (skinList != null && skinList.trim().length() > 0) { JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins")); StringTokenizer st = new StringTokenizer(skinList, ", "); ButtonGroup skinButtons = new ButtonGroup(); while (st.hasMoreTokens()) { final String nextSkin = st.nextToken(); final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin); skinMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setSkin(nextSkin); skinMenuItem.setSelected(true); } }); if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin"))) skinMenuItem.setSelected(true); skinsMenu.add(skinMenuItem); skinButtons.add(skinMenuItem); } optionsMenu.add(skinsMenu); } JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks")); ButtonGroup lookButtons = new ButtonGroup(); final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.default")); if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) { defaultLookMenuItem.setSelected(true); } lookFeelMenu.add(defaultLookMenuItem); lookButtons.add(defaultLookMenuItem); defaultLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("default"); defaultLookMenuItem.setSelected(true); } }); final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.system")); if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) { systemLookMenuItem.setSelected(true); } lookFeelMenu.add(systemLookMenuItem); lookButtons.add(systemLookMenuItem); systemLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("system"); systemLookMenuItem.setSelected(true); } }); String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks"); if (additionalLookList != null && additionalLookList.trim().length() > 0) { StringTokenizer st = new StringTokenizer(additionalLookList, ", "); while (st.hasMoreTokens()) { final String nextLook = st.nextToken(); final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook); lookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(nextLook); lookMenuItem.setSelected(true); } }); if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) { lookMenuItem.setSelected(true); } lookFeelMenu.add(lookMenuItem); lookButtons.add(lookMenuItem); } } optionsMenu.add(lookFeelMenu); optionsMenu.add(new UILanguageSelectionMenu(this)); mainMenuBar.add(optionsMenu); JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools")); final JMenuItem verbListMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.verblist")); verbListMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel(); VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode()); vlf.setVisible(true); } }); toolsMenu.add(verbListMenuItem); final JMenuItem validateMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.validatebsh")); validateMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel); if (!bscv.validate()) { BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText()); bsed.setVisible(true); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } else { JOptionPane.showMessageDialog(PuckFrame.this, UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!", JOptionPane.INFORMATION_MESSAGE); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } } }); toolsMenu.add(validateMenuItem); mainMenuBar.add(toolsMenu); JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help")); //JHelpAction.startHelpWorker("help/PUCKHelp.hs"); //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc")); //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context")); //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction); //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction); //helpMenu.add(helpTocMenuItem); //helpMenu.add(helpContextSensitiveMenuItem); final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc")); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true); dial.setVisible(true); } }); helpMenu.add(helpMenuItem); mainMenuBar.add(helpMenu); MenuMnemonicOnTheFly.setMnemonics(mainMenuBar); this.setJMenuBar(mainMenuBar); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { userExit(); } }); propPanel.show(graphPanel.getWorldNode()); setVisible(true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (dividerLoc > 0) split.setDividerLocation(dividerLoc); else split.setDividerLocation(0.60); } }); }
From source file:org.jab.docsearch.DocSearch.java
/** * Creates menu bar/* w w w .ja v a 2 s .c o m*/ * * @param menuBar Menu bar */ private JMenuBar createMenuBar() { // menu bar JMenuBar menuBar = new JMenuBar(); // ----- menu file // menu item print JMenuItem menuItemPrint = new JMenuItem(I18n.getString("menuitem.print")); menuItemPrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK)); menuItemPrint.setActionCommand("ac_print"); menuItemPrint.addActionListener(this); // scale X JRadioButtonMenuItem scaleXRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_width")); scaleXRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK)); scaleXRadioBut.addActionListener(new ScaleXListener()); // scale Y JRadioButtonMenuItem scaleYRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_length")); scaleYRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)); scaleYRadioBut.addActionListener(new ScaleYListener()); // scale fit JRadioButtonMenuItem scaleFitRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_to_fit")); scaleFitRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); scaleFitRadioBut.addActionListener(new ScaleFitListener()); // scale half JRadioButtonMenuItem scaleHalfRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_half")); scaleHalfRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)); scaleHalfRadioBut.addActionListener(new ScaleHalfListener()); // scale double JRadioButtonMenuItem scale2RadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_2x")); scale2RadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK)); scale2RadioBut.addActionListener(new Scale2Listener()); // scale off JRadioButtonMenuItem scaleOffRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_off"), true); scaleOffRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)); ButtonGroup scaleSetGroup = new ButtonGroup(); scaleSetGroup.add(scale2RadioBut); scaleSetGroup.add(scaleFitRadioBut); scaleSetGroup.add(scaleHalfRadioBut); scaleSetGroup.add(scaleOffRadioBut); scaleSetGroup.add(scaleXRadioBut); scaleSetGroup.add(scaleYRadioBut); // build complete menu print preferences JMenu menuPrintPref = new JMenu(I18n.getString("menuitem.print_preferences"), true); menuPrintPref.add(scaleXRadioBut); menuPrintPref.add(scaleYRadioBut); menuPrintPref.add(scaleFitRadioBut); menuPrintPref.add(scaleHalfRadioBut); menuPrintPref.add(scale2RadioBut); menuPrintPref.addSeparator(); menuPrintPref.add(scaleOffRadioBut); // menu item exit JMenuItem menuItemExit = new JMenuItem(I18n.getString("menuitem.exit")); menuItemExit.setActionCommand("ac_exit"); menuItemExit.addActionListener(this); // build complete menu file JMenu menuFile = new JMenu(I18n.getString("menu.file")); menuFile.add(menuItemPrint); menuFile.add(menuPrintPref); menuFile.addSeparator(); menuFile.add(menuItemExit); // add menu to menu bar menuBar.add(menuFile); // ----- menu index // menu item new JMenuItem menuItemNewIndex = new JMenuItem(I18n.getString("menuitem.new_index")); menuItemNewIndex.setActionCommand("ac_newindex"); menuItemNewIndex.addActionListener(this); // menu item new spider JMenuItem menuItemNewSpiderIndex = new JMenuItem(I18n.getString("menuitem.new_spider_index")); menuItemNewSpiderIndex.setActionCommand("ac_newspiderindex"); menuItemNewSpiderIndex.addActionListener(this); // menu item manage JMenuItem menuItemManageIndex = new JMenuItem(I18n.getString("menuitem.manage_indexes")); menuItemManageIndex.setActionCommand("ac_manageindex"); menuItemManageIndex.addActionListener(this); // menu item rebuild JMenuItem menuItemRebuildIndex = new JMenuItem(I18n.getString("menuitem.rebuild_all_indexes")); menuItemRebuildIndex.setActionCommand("ac_rebuildindexes"); menuItemRebuildIndex.addActionListener(this); // menu item import JMenuItem menuItemImportIndex = new JMenuItem(I18n.getString("menuitem.import_index")); menuItemImportIndex.setActionCommand("ac_importindex"); menuItemImportIndex.addActionListener(this); // build complete menu index JMenu indexMenu = new JMenu(I18n.getString("menu.index")); indexMenu.add(menuItemNewIndex); indexMenu.add(menuItemNewSpiderIndex); indexMenu.add(menuItemManageIndex); indexMenu.add(menuItemRebuildIndex); indexMenu.addSeparator(); indexMenu.add(menuItemImportIndex); // add menu to menu bar menuBar.add(indexMenu); // ----- menu bookmark // menu item add JMenuItem menuItemAddBookmark = new JMenuItem(I18n.getString("menuitem.add_bookmark")); menuItemAddBookmark.setActionCommand("ac_addbookmark"); menuItemAddBookmark.addActionListener(this); // menu item delete all JMenuItem menuItemDeleteAll = new JMenuItem(I18n.getString("menuitem.delete_all_bookmarks")); menuItemDeleteAll.setActionCommand("ac_deleteallbookmarks"); menuItemDeleteAll.addActionListener(this); // build complete menu index bookMarkMenu = new JMenu(I18n.getString("menu.bookmarks")); bookMarkMenu.add(menuItemAddBookmark); bookMarkMenu.add(menuItemDeleteAll); bookMarkMenu.addSeparator(); // add menu to menu bar menuBar.add(bookMarkMenu); // ----- menu report // menu item metadata report JMenuItem menuItemMetadataReport = new JMenuItem(I18n.getString("menuitem.metadata_report")); menuItemMetadataReport.setActionCommand("ac_metadata_report"); menuItemMetadataReport.addActionListener(this); // menu item servlet report JMenuItem menuItemServletReport = new JMenuItem(I18n.getString("menuitem.servlet_log_report")); menuItemServletReport.setActionCommand("ac_servlet_log_report"); menuItemServletReport.addActionListener(this); // build complete menu report JMenu reportMenu = new JMenu(I18n.getString("menu.reports")); reportMenu.add(menuItemMetadataReport); reportMenu.add(menuItemServletReport); // add menu to menu bar menuBar.add(reportMenu); // ----- menu tools // menu item makr cd JMenuItem menuItemMakeCD = new JMenuItem(I18n.getString("menuitem.make_cd")); menuItemMakeCD.setActionCommand("ac_makecd"); menuItemMakeCD.addActionListener(this); // menu item setting JMenuItem menuItemSetting = new JMenuItem(I18n.getString("menuitem.settings")); menuItemSetting.setActionCommand("ac_settings"); menuItemSetting.addActionListener(this); // build complete menu report JMenu menuTool = new JMenu(I18n.getString("menu.tools")); menuTool.add(menuItemMakeCD); menuTool.addSeparator(); menuTool.add(menuItemSetting); // add menu to menu bar menuBar.add(menuTool); // ----- menu help // menu item search tip JMenuItem menuItemSearchTip = new JMenuItem(I18n.getString("menuitem.search_tips")); menuItemSearchTip.setActionCommand("ac_search_tips"); menuItemSearchTip.addActionListener(this); // menu item about JMenuItem menuItemAbout = new JMenuItem(I18n.getString("menuitem.about")); menuItemAbout.setActionCommand("ac_about"); menuItemAbout.addActionListener(this); // build complete menu help JMenu menuHelp = new JMenu(I18n.getString("menu.help")); menuHelp.add(menuItemSearchTip); menuHelp.add(menuItemAbout); // add menu to menu bar menuBar.add(menuHelp); // finished return menuBar; }