List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
From source file:org.esa.snap.core.gpf.ui.OperatorMenu.java
/** * Creates the default menu.// w ww .ja v a2 s.c om * * @return The menu */ public JMenuBar createDefaultMenu() { JMenu fileMenu = new JMenu("File"); fileMenu.add(loadParametersAction); fileMenu.add(saveParametersAction); fileMenu.addSeparator(); fileMenu.add(displayParametersAction); JMenu helpMenu = new JMenu("Help"); helpMenu.add(createHelpMenuItem()); helpMenu.add(aboutAction); final JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(helpMenu); return menuBar; }
From source file:org.intermine.install.swing.ProjectEditor.java
/** * Common initialisation: lays out the child components and wires up the necessary * event listeners. //w ww .java 2s .co m */ private void init() { setName("Project Editor Frame"); setTitle(Messages.getMessage("projecteditor.title")); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new MyWindowListener()); modelViewerFrame = new JFrame(); modelViewerFrame.setName("Model Viewer Frame"); modelViewer = new ModelViewer(); modelViewerFrame.setContentPane(modelViewer); modelViewerFrame.setTitle(Messages.getMessage("modelviewer.title")); modelViewerFrame.setSize(800, 600); newMineDialog = new NewMineDialog(this); createDatabaseDialog = new CreateDatabaseDialog(this); newMineDialog.setCreateDatabaseDialog(createDatabaseDialog); createPropertiesDialog = new CreatePropertiesDialog(this); createDatabaseDialog.setCreatePropertiesDialog(createPropertiesDialog); makeMineDialog = new MakeMineDialog(this); createPropertiesDialog.setMakeMineDialog(makeMineDialog); addSourceDialog = new AddSourceDialog(this); newDerivedSourceDialog = new NewDerivedTypeDialog(this); addSourceDialog.setNewDerivedDialog(newDerivedSourceDialog); postProcessorDialog = new PostProcessorDialog(this); buildProjectDialog = new BuildProjectDialog(this); preferencesDialog = new PreferencesDialog(this); ProjectListener projectListener = new MyProjectListener(); addSourceDialog.addProjectListener(projectListener); newDerivedSourceDialog.addProjectListener(projectListener); postProcessorDialog.addProjectListener(projectListener); sourcePanel.addProjectListener(projectListener); makeMineDialog.addProjectListener(projectListener); addProjectListener(projectListener); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu fileMenu = new JMenu(Messages.getMessage("file")); fileMenu.setMnemonic(KeyEvent.VK_P); menuBar.add(fileMenu); fileMenu.add(new NewMineAction()); fileMenu.add(new OpenAction()); fileMenu.addSeparator(); fileMenu.add(saveAction); fileMenu.addSeparator(); fileMenu.add(buildProjectAction); JMenu editMenu = new JMenu(Messages.getMessage("edit")); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu); editMenu.add(addSourceAction); editMenu.add(deleteSourceAction); editMenu.addSeparator(); editMenu.add(postProcessorAction); JMenu viewMenu = new JMenu(Messages.getMessage("view")); viewMenu.setMnemonic(KeyEvent.VK_M); menuBar.add(viewMenu); viewMenu.add(new ViewModelAction()); JMenu toolsMenu = new JMenu(Messages.getMessage("tools")); toolsMenu.setMnemonic(KeyEvent.VK_T); menuBar.add(toolsMenu); toolsMenu.add(new PreferencesAction()); sourceListModel = new SourceListModel(); sourceList = new JList(sourceListModel); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); cp.add(splitPane, BorderLayout.CENTER); initButtonPanel(); Box vbox = Box.createVerticalBox(); vbox.add(sourcePanel); vbox.add(buttonPanel); splitPane.setLeftComponent(new JScrollPane(sourceList)); splitPane.setRightComponent(vbox); splitPane.setDividerLocation(200); initStatusPanel(); cp.add(statusPanel, BorderLayout.SOUTH); sourceList.setCellRenderer(new SourceListRenderer()); sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); sourceList.addListSelectionListener(new SourceListSelectionListener()); statusMessageClearTimer = new Timer(4000, new StatusMessageClearer()); statusMessageClearTimer.setInitialDelay(4000); statusMessageClearTimer.setRepeats(false); setSize(800, 600); }
From source file:org.interreg.docexplore.authoring.AuthoringMenu.java
public AuthoringMenu(final AuthoringToolFrame authoringTool) { this.tool = authoringTool; this.recent = new LinkedList<String>(); readRecent();// ww w . ja v a 2 s . c om this.file = new JMenu(XMLResourceBundle.getBundledString("generalMenuFile")); add(file); newItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuNew")) { public void actionPerformed(ActionEvent arg0) { newFile(); } }); loadItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuLoad")) { public void actionPerformed(ActionEvent arg0) { load(); } }); saveItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSave")) { public void actionPerformed(ActionEvent arg0) { save(); } }); saveAsItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSaveAs")) { public void actionPerformed(ActionEvent arg0) { saveAs(); } }); exportItem = new JMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("generalMenuExport") + "...") { public void actionPerformed(ActionEvent arg0) { GuiUtils.blockUntilComplete(new ProgressRunnable() { public void run() { try { authoringTool.readerExporter.doExport(authoringTool.editor.link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) authoringTool.readerExporter.progress[0]; } }, authoringTool.editor); } }); webExportItem = new JMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("generalMenuWebExport") + "...") { public void actionPerformed(ActionEvent arg0) { GuiUtils.blockUntilComplete(new ProgressRunnable() { public void run() { try { authoringTool.webExporter.doExport(authoringTool.editor.link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (authoringTool.webExporter.copyComplete ? .5f : 0f) + (float) (.5 * authoringTool.webExporter.progress[0]); } }, authoringTool.editor); } }); // webExportItem = new JMenuItem(new AbstractAction("Web export") {public void actionPerformed(ActionEvent arg0) // { // GuiUtils.blockUntilComplete(new Runnable() {public void run() // { // try // { // new WebStaticExporter().doExport(authoringTool.editor.link.getBook(authoringTool.editor.link.getLink().getAllBookIds().get(0))); // } // catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex);} // }}, authoringTool.editor); // }}); // webExportItem.setEnabled(false); quitItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuQuit")) { public void actionPerformed(ActionEvent arg0) { authoringTool.quit(); } }); buildFileMenu(); JMenu edit = new JMenu(XMLResourceBundle.getBundledString("generalMenuEdit")); this.undoItem = new JMenuItem(); undoItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { authoringTool.historyManager.undo(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); edit.add(undoItem); this.redoItem = new JMenuItem(); redoItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { authoringTool.historyManager.redo(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); edit.add(redoItem); JMenuItem viewHistory = new JMenuItem(XMLResourceBundle.getBundledString("generalMenuEditViewHistory")); viewHistory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { authoringTool.historyDialog.setVisible(true); } }); edit.add(viewHistory); edit.addSeparator(); edit.add(new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("fixChars")) { public void actionPerformed(ActionEvent arg0) { Object res = JOptionPane.showInputDialog(tool, XMLResourceBundle.getBundledString("fixCharsMsg"), XMLResourceBundle.getBundledString("fixChars"), JOptionPane.QUESTION_MESSAGE, null, new Object[] { XMLResourceBundle.getBundledString("fixCharsWin"), XMLResourceBundle.getBundledString("fixCharsMac") }, XMLResourceBundle.getBundledString("fixCharsWin")); if (res == null) return; try { convertPresentation(tool.defaultFile, res.equals(XMLResourceBundle.getBundledString("fixCharsWin")) ? "ISO-8859-1" : "x-MacRoman"); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e); } try { tool.editor.reset(); } catch (Exception e) { e.printStackTrace(); } } })); //TODO: remove! // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // if (regions.size() > 2) // { // Region highest = null; // int max = -1; // for (Region region : regions) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; highest = region;} // Region middle = null; // max = -1; // for (Region region : regions) // if (region != highest) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; middle = region;} // if (regions.size() > 3) // { // max = -1; // Region newMiddle = null; // for (Region region : regions) // if (region != highest && region != middle) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; newMiddle = region;} // middle = newMiddle; // } // MetaDataKey display = book.getLink().getKey("display", ""); // for (Map.Entry<MetaDataKey, List<MetaData>> entry : highest.getMetaData().entrySet()) // for (MetaData md : entry.getValue()) // if (md.getType().equals(MetaData.textType)) // { // String val = "<b>"+md.getString()+"</b>\n"; // for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet()) // for (MetaData md2 : entry2.getValue()) // if (md2.getType().equals(MetaData.textType) && TextElement.getStyle(md, tool.styleManager) == TextElement.getStyle(md2, tool.styleManager)) // val = val+"\n"+md2.getString(); // md.setString(val); // } // boolean hasImage = false; // for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet()) // for (MetaData md2 : entry2.getValue()) // if (md2.getType().equals(MetaData.imageType)) // { // MetaData imageMd = new MetaData(book.getLink(), display, md2.getType(), md2.getValue()); // if (!hasImage) // BookImporter.insert(imageMd, highest, 0); // else BookImporter.insert(imageMd, highest, BookImporter.getHighestRank(highest)+1); // hasImage = true; // } // page.removeRegion(middle); // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // MetaDataKey display = book.getLink().getKey("display", ""); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // for (Region region : regions) // { // List<MetaData> mds = region.getMetaDataListForKey(display); // for (MetaData md : mds) // if (md.getType().equals(MetaData.textType)) // { // String val = md.getString().trim(); // if (!val.startsWith("<i>") || !val.endsWith("</i>")) // continue; // TextElement.getStyleMD(md).setString("4"); // md.setString(val.substring(3, val.length()-4)); // System.out.println(md.getString()); // } // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // MetaDataKey display = book.getLink().getKey("display", ""); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // for (Region region : regions) // { // int max = BookImporter.getHighestRank(region); // for (int i=0;i<max;i++) // { // MetaData md1 = BookImporter.getAtRank(region, i); // if (md1 == null || !md1.getType().equals(MetaData.textType)) // continue; // MetaData style1 = TextElement.getStyleMD(md1); // if (!style1.getString().equals("0")) // continue; // MetaData md2 = BookImporter.getAtRank(region, i+1); // if (md2 == null || !md2.getType().equals(MetaData.textType)) // continue; // MetaData style2 = TextElement.getStyleMD(md2); // if (!style2.getString().equals("1")) // continue; // BookImporter.setRank(md1, i+1); // BookImporter.setRank(md2, i); // i++; // } // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // MetaDataKey mini = book.getLink().getOrCreateKey("mini", ""); // MetaDataKey dim = book.getLink().getOrCreateKey("dimension", ""); // int lastPage = book.getLastPageNumber(); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // List<MetaData> mds = page.getMetaDataListForKey(mini); // if (mds != null) // for (MetaData md : mds) // page.removeMetaData(md); // mds = page.getMetaDataListForKey(dim); // if (mds != null) // for (MetaData md : mds) // page.removeMetaData(md); // DocExploreDataLink.getImageDimension(page, true); // DocExploreDataLink.getImageMini(page, false); // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); add(edit); JMenu view = new JMenu(XMLResourceBundle.getBundledString("generalMenuView")); add(view); JMenuItem styles = new JMenuItem(XMLResourceBundle.getBundledString("styleEdit") + "...", ImageUtils.getIcon("pencil-24x24.png")); styles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { authoringTool.styleManager.styleDialog.setVisible(true); } }); view.add(styles); helpToggle = new JCheckBoxMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("viewHelpToggle")) { public void actionPerformed(ActionEvent arg0) { authoringTool.displayHelp = helpToggle.isSelected(); authoringTool.repaint(); } }); helpToggle.setSelected(tool.startup.showHelp); view.add(helpToggle); JMenu helpMenu = new JMenu(XMLResourceBundle.getString("management-lrb", "generalMenuHelp")); if (Desktop.isDesktopSupported()) { final Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { helpMenu.add(new AbstractAction( XMLResourceBundle.getString("management-lrb", "generalMenuHelpContents")) { public void actionPerformed(ActionEvent e) { try { File doc = new File(DocExploreTool.getExecutableDir(), "MMT documentation.htm"); desktop.open(doc); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex, true); } } }); helpMenu.add(new AbstractAction( XMLResourceBundle.getString("management-lrb", "generalMenuHelpWebsite")) { public void actionPerformed(ActionEvent e) { try { File link = new File(DocExploreTool.getExecutableDir(), "website.url"); desktop.open(link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex, true); } } }); } } helpMenu.add(new AbstractAction(XMLResourceBundle.getString("management-lrb", "generalMenuHelpAbout")) { public void actionPerformed(ActionEvent e) { final JDialog splash = new JDialog(tool, true); splash.setLayout(new BorderLayout()); SplashScreen screen = new SplashScreen("logoAT.png"); splash.add(screen, BorderLayout.NORTH); screen.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { splash.setVisible(false); } }); splash.setUndecorated(true); screen.setText( "<html>DocExplore 2009-2014" + "<br/>Released under the CeCILL v2.1 license" + "</html>"); splash.pack(); splash.setAlwaysOnTop(true); GuiUtils.centerOnScreen(splash); splash.setVisible(true); } }); add(helpMenu); historyChanged(authoringTool.historyManager); authoringTool.historyManager.addHistoryListener(this); }
From source file:org.jab.docsearch.DocSearch.java
/** * Creates menu bar/*from w w w . j a v a 2s . c om*/ * * @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; }
From source file:org.javaswift.cloudie.CloudiePanel.java
public JMenuBar createMenuBar() { JMenuBar bar = new JMenuBar(); JMenu accountMenu = new JMenu("Account"); JMenu containerMenu = new JMenu("Container"); JMenu storedObjectMenu = new JMenu("StoredObject"); JMenu helpMenu = new JMenu("Help"); accountMenu.setMnemonic('A'); containerMenu.setMnemonic('C'); storedObjectMenu.setMnemonic('O'); helpMenu.setMnemonic('H'); bar.add(accountMenu);/* www . j av a 2 s . com*/ bar.add(containerMenu); bar.add(storedObjectMenu); bar.add(helpMenu); JPanel panel = new JPanel(new FlowLayout(SwingConstants.RIGHT, 0, 0)); JLabel label = new JLabel(getIcon("zoom.png")); label.setLabelFor(searchTextField); label.setDisplayedMnemonic('f'); panel.add(label); panel.add(searchTextField); bar.add(panel); // accountMenu.add(new JMenuItem(accountLoginAction)); accountMenu.add(new JMenuItem(accountLogoutAction)); accountMenu.addSeparator(); accountMenu.add(new JMenuItem(accountQuitAction)); // containerMenu.add(new JMenuItem(containerRefreshAction)); containerMenu.add(new JMenuItem(containerViewMetaData)); containerMenu.addSeparator(); containerMenu.add(new JMenuItem(containerCreateAction)); containerMenu.add(new JMenuItem(containerDeleteAction)); containerMenu.addSeparator(); containerMenu.add(new JMenuItem(containerEmptyAction)); containerMenu.addSeparator(); containerMenu.add(new JMenuItem(containerPurgeAction)); // storedObjectMenu.add(new JMenuItem(storedObjectPreviewAction)); storedObjectMenu.add(new JMenuItem(storedObjectOpenAction)); storedObjectMenu.add(new JMenuItem(storedObjectViewMetaData)); storedObjectMenu.addSeparator(); storedObjectMenu.add(new JMenuItem(storedObjectCreateAction)); storedObjectMenu.add(new JMenuItem(storedObjectDownloadAction)); storedObjectMenu.addSeparator(); storedObjectMenu.add(new JMenuItem(storedObjectDeleteAction)); // helpMenu.add(new JMenuItem(aboutAction)); // return bar; }
From source file:org.jcurl.demo.editor.EditorApp.java
private JMenuBar createMenu() { final JMenuBar bar = new JMenuBar(); {// ww w . ja va 2 s.c o m final JMenu menu = bar.add(new JMenu("File")); menu.setMnemonic('F'); menu.add(this.newMI("New", null, 'N', -1, this, "cmdNew")); menu.add(this.newMI("Open", null, 'O', KeyEvent.VK_O, this, "cmdOpen")); menu.addSeparator(); menu.add(this.newMI("Export Png", null, 'P', KeyEvent.VK_E, this, "cmdExportPng")); menu.addSeparator(); menu.add(this.newMI("Save", null, 'S', KeyEvent.VK_S, this, "cmdSave")); menu.add(this.newMI("Save As", null, 'A', -1, this, "cmdSaveAs")); menu.addSeparator(); menu.add(this.newMI("Exit", null, 'x', -1, this, "cmdExit")); } { final JMenu menu = bar.add(new JMenu("View")); menu.setMnemonic('V'); menu.add(this.newMI("Zoom", null, 'z', -1, this, "cmdZoom")); } { final JMenu menu = bar.add(new JMenu("Play")); menu.setMnemonic('P'); menu.add(this.newMI('a', -1, bStart.getAction())); menu.add(this.newMI('P', -1, bPause.getAction())); menu.add(this.newMI('o', -1, bStop.getAction())); } { final JMenu menu = bar.add(new JMenu("Help")); menu.setMnemonic('H'); menu.add(this.newMI("About", null, 'a', -1, this, "cmdAbout")); } return bar; }
From source file:org.jcurl.demo.tactics.old.ActionRegistry.java
private void addMenuItem(final Object controller, final JMenu ret, final Method m) { final JCAction a = m.getAnnotation(JCAction.class); if (a.separated()) ret.addSeparator(); final JMenuItem mi = new JMenuItem(); mi.setAction(findAction(controller, m)); {//ww w . j a va2 s.c o m // TODO move to createAction final Character mne = findMnemonic(a.title()); if (mne != null) mi.setMnemonic(mne); } ret.add(mi); }
From source file:org.jcurl.demo.tactics.TacticsApp.java
private JMenuBar createMenu() { final JMenuBar bar = new JMenuBar(); {//ww w .ja v a2 s . com final JMenu menu = bar.add(new JMenu("File")); menu.setMnemonic('F'); menu.add(this.newMI("New", null, 'N', -1, this, "cmdNew")); menu.add(this.newMI("Open", null, 'O', KeyEvent.VK_O, this, "cmdOpen")); menu.addSeparator(); menu.add(this.newMI("Export Png", null, 'P', KeyEvent.VK_E, this, "cmdExportPng")); menu.addSeparator(); menu.add(this.newMI("Save", null, 'S', KeyEvent.VK_S, this, "cmdSave")); menu.add(this.newMI("Save As", null, 'A', -1, this, "cmdSaveAs")); menu.addSeparator(); menu.add(this.newMI("Exit", null, 'x', -1, this, "cmdExit")); } { final JMenu menu = bar.add(new JMenu("View")); menu.setMnemonic('V'); menu.add(this.newMI("Zoom", null, 'z', -1, this, "cmdZoom")); } { final JMenu menu = bar.add(new JMenu("Play")); menu.setMnemonic('P'); menu.setEnabled(false); // menu.add(newMI('a', -1, bStart.getAction())); // menu.add(newMI('P', -1, bPause.getAction())); // menu.add(newMI('o', -1, bStop.getAction())); } { final JMenu menu = bar.add(new JMenu("Help")); menu.setMnemonic('H'); menu.add(this.newMI("About", null, 'a', -1, this, "cmdAbout")); } return bar; }
From source file:org.kepler.gui.MenuMapper.java
public static JMenuItem addMenuFor(String key, Action action, JComponent topLvlContainer, Map<String, JMenuItem> keplerMenuMap) { if (topLvlContainer == null) { if (isDebugging) { log.debug("NULL container received (eg JMenuBar) - returning NULL"); }// w ww . ja va 2 s .c o m return null; } if (key == null) { if (isDebugging) { log.debug("NULL key received"); } return null; } key = key.trim(); if (key.length() < 1) { if (isDebugging) { log.debug("BLANK key received"); } return null; } if (action == null && key.indexOf(MENU_SEPARATOR_KEY) < 0) { if (isDebugging) { log.debug("NULL action received, but was not a separator: " + key); } return null; } if (keplerMenuMap.containsKey(key)) { if (isDebugging) { log.debug("Menu already added; skipping: " + key); } return null; } // split delimited parts and ensure menus all exist String[] menuLevel = key.split(MENU_PATH_DELIMITER); int totLevels = menuLevel.length; // create a menu for each "menuLevel" if it doesn't already exist final StringBuffer nextLevelBuff = new StringBuffer(); String prevLevelStr = null; JMenuItem leafMenuItem = null; for (int levelIdx = 0; levelIdx < totLevels; levelIdx++) { // save previous value prevLevelStr = nextLevelBuff.toString(); String nextLevelStr = menuLevel[levelIdx]; // get the index of the first MNEMONIC_SYMBOL int mnemonicIdx = nextLevelStr.indexOf(MNEMONIC_SYMBOL); char mnemonicChar = 0; // if an MNEMONIC_SYMBOL exists, remove all underscores. Then, idx // of // first underscore becomes idx of letter it used to precede - this // is the mnemonic letter if (mnemonicIdx > -1) { nextLevelStr = nextLevelStr.replaceAll(MNEMONIC_SYMBOL, ""); mnemonicChar = nextLevelStr.charAt(mnemonicIdx); } if (levelIdx != 0) { nextLevelBuff.append(MENU_PATH_DELIMITER); } nextLevelBuff.append(nextLevelStr); // don't add multiple separators together... if (nextLevelStr.indexOf(MENU_SEPARATOR_KEY) > -1) { if (separatorJustAdded == false) { // Check if we're at the top level, since this makes sense // only for // context menu - we can't add a separator to a JMenuBar if (levelIdx == 0) { if (topLvlContainer instanceof JContextMenu) { ((JContextMenu) topLvlContainer).addSeparator(); } } else { JMenu parent = (JMenu) keplerMenuMap.get(prevLevelStr); if (parent != null) { if (parent.getMenuComponentCount() < 1) { if (isDebugging) { log.debug("------ NOT adding separator to parent " + parent.getText() + ", since it does not contain any menu items"); } } else { if (isDebugging) { log.debug("------ adding separator to parent " + parent.getText()); } // add separator to parent parent.addSeparator(); separatorJustAdded = true; } } } } } else if (!keplerMenuMap.containsKey(nextLevelBuff.toString())) { // If menu has not already been created, we need // to create it and then add it to the parent level... JMenuItem menuItem = null; // if we're at a "leaf node" - need to create a JMenuItem if (levelIdx == totLevels - 1) { // save old display name to use as actionCommand on // menuitem, // since some parts of PTII still // use "if (actionCommand.equals("SaveAs")) {..." etc String oldDisplayName = (String) action.getValue(Action.NAME); // action.putValue(Action.NAME, nextLevelStr); if (mnemonicChar > 0) { action.putValue(GUIUtilities.MNEMONIC_KEY, new Integer(mnemonicChar)); } // Now we look to see if it's a checkbox // menu item, or just a regular one String menuItemType = (String) (action.getValue(MENUITEM_TYPE)); if (menuItemType != null && menuItemType == CHECKBOX_MENUITEM_TYPE) { menuItem = new JCheckBoxMenuItem(action); } else { menuItem = new JMenuItem(action); } // -------------------------------------------------------------- /** @todo - setting menu names - TEMPORARY FIX - FIXME */ // Currently, if we use the "proper" way of setting menu // names - // ie by using action.putValue(Action.NAME, "somename");, // then // the name appears on the port buttons on the toolbar, // making // them huge. As a temporary stop-gap, I am just setting the // new // display name using setText() instead of // action.putValue(.., // but this needs to be fixed elsewhere - we want to be able // to // use action.putValue(Action.NAME (ie uncomment the line // above // that reads: // action.putValue(Action.NAME, nextLevelStr); // and delete the line below that reads: // menuItem.setText(nextLevelStr); // otherwise this may bite us in future... menuItem.setText(nextLevelStr); // -------------------------------------------------------------- // set old display name as actionCommand on // menuitem, for ptii backward-compatibility menuItem.setActionCommand(oldDisplayName); // add JMenuItem to the Action, so it can be accessed by // Action code action.putValue(NEW_JMENUITEM_KEY, menuItem); leafMenuItem = menuItem; } else { // if we're *not* at a "leaf node" - need to create a JMenu menuItem = new JMenu(nextLevelStr); if (mnemonicChar > 0) { menuItem.setMnemonic(mnemonicChar); } } // level 0 is a special case, since the container (JMenuBar or // JContextMenu) is not a JMenu or a JMenuItem, so we can't // use the same code to add child to parent... if (levelIdx == 0) { if (topLvlContainer instanceof JMenuBar) { // this handles JMenuBar menus ((JMenuBar) topLvlContainer).add(menuItem); } else if (topLvlContainer instanceof JContextMenu) { // this handles popup context menus ((JContextMenu) topLvlContainer).add(menuItem); } // add to Map keplerMenuMap.put(nextLevelBuff.toString(), menuItem); separatorJustAdded = false; } else { JMenu parent = (JMenu) keplerMenuMap.get(prevLevelStr); if (parent != null) { // add to parent parent.add(menuItem); // add to Map keplerMenuMap.put(nextLevelBuff.toString(), menuItem); separatorJustAdded = false; } else { if (isDebugging) { log.debug("Parent menu is NULL" + prevLevelStr); } } } } } return leafMenuItem; }
From source file:org.kuali.test.ui.components.panels.BaseCreateTestPanel.java
/** * * @return/*from ww w .j ava2s .c om*/ */ protected JMenuBar createOperationPanel() { JMenuBar retval = new JMenuBar(); JMenu menu = new JMenu(Constants.OPERATION_ACTION) { @Override public Insets getInsets() { return new Insets(1, 5, 1, 200); } }; menu.setMnemonic('o'); cancelTest = new JMenuItem(Constants.CANCEL_TEST_ACTION); cancelTest.setMnemonic('c'); saveTest = new JMenuItem(Constants.SAVE_TEST_ACTION); createCheckpoint = new JMenuItem(Constants.CREATE_CHECKPOINT_ACTION); createComment = new JMenuItem(Constants.CREATE_COMMENT_ACTION); createParameter = new JMenuItem(Constants.CREATE_PARAMETER_ACTION); viewCheckpoints = new JMenuItem(Constants.VIEW_CHECKPOINTS_ACTION); viewComments = new JMenuItem(Constants.VIEW_COMMENTS_ACTION); viewParameters = new JMenuItem(Constants.VIEW_PARAMETERS_ACTION); menu.add(cancelTest); menu.add(saveTest); menu.addSeparator(); menu.add(createCheckpoint); menu.add(createComment); if (isParameterOperationRequired()) { menu.add(createParameter); } menu.addSeparator(); menu.add(viewCheckpoints); menu.add(viewComments); if (isParameterOperationRequired()) { menu.add(viewParameters); } cancelTest.addActionListener(this); saveTest.addActionListener(this); createCheckpoint.addActionListener(this); createComment.addActionListener(this); if (isParameterOperationRequired()) { createParameter.addActionListener(this); } viewCheckpoints.addActionListener(this); viewComments.addActionListener(this); if (isParameterOperationRequired()) { viewParameters.addActionListener(this); } retval.add(menu); StringBuilder txt = new StringBuilder(128); txt.append("<html><span style='font-weight: 700;'>Platform: </span><span style='color: "); txt.append(Constants.COLOR_DARK_BLUE); txt.append("; font-weight: normal;'>"); txt.append(platform.getName()); txt.append( "</span><span style='font-weight: 700; padding-left: 30px;'>, Test Type: </span><span style='color: "); txt.append(Constants.COLOR_DARK_BLUE); txt.append("; font-weight: normal;'>"); txt.append(testHeader.getTestType().toString()); txt.append( "</span><span style='font-weight: 700; padding-left: 30px;'>, Test Name: </span><span style='color: "); txt.append(Constants.COLOR_DARK_BLUE); txt.append("; font-weight: normal;'>"); txt.append(testHeader.getTestName()); txt.append("</span></html>"); retval.add(new JLabel(txt.toString())); return retval; }