List of usage examples for javax.swing JMenuBar add
public JMenu add(JMenu c)
From source file:org.genedb.jogra.plugins.TermRationaliser.java
/** * Return a new JFrame which is the main interface to the Rationaliser. *//*from ww w . j av a 2s.c om*/ public JFrame getMainPanel() { /* JFRAME */ frame.setTitle(WINDOW_TITLE); frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.setLayout(new BorderLayout()); /* MENU */ JMenuBar menuBar = new JMenuBar(); JMenu actions_menu = new JMenu("Actions"); JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists"); actions_mitem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { initModels(); } }); actions_menu.add(actions_mitem_1); JMenu about_menu = new JMenu("About"); JMenuItem about_mitem_1 = new JMenuItem("About"); about_mitem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JOptionPane.showMessageDialog(null, "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009", "Term Rationaliser", JOptionPane.PLAIN_MESSAGE); } }); about_menu.add(about_mitem_1); menuBar.add(about_menu); menuBar.add(actions_menu); frame.add(menuBar, BorderLayout.NORTH); /* MAIN BOX */ Box center = Box.createHorizontalBox(); //A box that displays contents from left to right center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component /* FROM LIST AND PANEL */ fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected fromList.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) { synchroniseLists(fromList, toList); //synchronise from left to right } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side fromPanel.add(Box.createVerticalStrut(55)); //Add some space center.add(fromPanel); //Add to main box center.add(Box.createHorizontalStrut(3)); //Add some space /* MIDDLE PANE */ Box middlePane = Box.createVerticalBox(); ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif")); ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif")); leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon! rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon! JButton rightSynch = new JButton(rightButtonIcon); rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key"); rightSynch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { synchroniseLists(fromList, toList); } }); JButton leftSynch = new JButton(leftButtonIcon); leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key"); leftSynch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { synchroniseLists(toList, fromList); } }); middlePane.add(rightSynch); middlePane.add(leftSynch); center.add(middlePane); //Add middle pane to main box center.add(Box.createHorizontalStrut(3)); /* TO LIST AND PANEL */ toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list toList.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_LEFT) { synchroniseLists(toList, fromList); //synchronise from right to left } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList); Box newTerm = Box.createVerticalBox(); textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10)); textField.setForeground(Color.BLUE); JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); newTerm.add(jsp); TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name"); editBorder.setTitleColor(Color.DARK_GRAY); newTerm.setBorder(editBorder); toPanel.add(newTerm); //add textfield to panel center.add(toPanel); //add panel to main box center.add(Box.createHorizontalStrut(5)); frame.add(center); //add the main panel to the frame initModels(); //load the lists with data /* BOTTOM HALF OF FRAME */ Box main = Box.createVerticalBox(); TitledBorder border = BorderFactory.createTitledBorder("Information"); border.setTitleColor(Color.DARK_GRAY); /* INFORMATION BOX */ Box info = Box.createVerticalBox(); Box scope = Box.createHorizontalBox(); scope.add(Box.createHorizontalStrut(5)); scope.add(scopeLabel); //label showing the scope of the terms scope.add(Box.createHorizontalGlue()); Box productCount = Box.createHorizontalBox(); productCount.add(Box.createHorizontalStrut(5)); productCount.add(productCountLabel); //display the label showing the number of terms productCount.add(Box.createHorizontalGlue()); info.add(scope); info.add(productCount); info.setBorder(border); /* ACTION BUTTONS */ Box actionButtons = Box.createHorizontalBox(); actionButtons.add(Box.createHorizontalGlue()); actionButtons.add(Box.createHorizontalStrut(10)); JButton findFix = new JButton(new FindClosestMatchAction()); actionButtons.add(findFix); actionButtons.add(Box.createHorizontalStrut(10)); RationaliserAction ra = new RationaliserAction(); // RationaliserAction2 ra2 = new RationaliserAction2(); JButton go = new JButton(ra); actionButtons.add(go); actionButtons.add(Box.createHorizontalGlue()); /* MORE INFORMATION TOGGLE */ Box buttonBox = Box.createHorizontalBox(); final JButton toggle = new JButton("Hide information <<"); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(toggle); buttonBox.add(Box.createHorizontalGlue()); Box textBox = Box.createHorizontalBox(); final JScrollPane scrollPane = new JScrollPane(information); scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100)); scrollPane.setVisible(true); textBox.add(Box.createHorizontalStrut(5)); textBox.add(scrollPane); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (toggle.getText().equals("Show information >>")) { scrollPane.setVisible(true); toggle.setText("Hide information <<"); frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100)); frame.pack(); } else if (toggle.getText().equals("Hide information <<")) { scrollPane.setVisible(false); toggle.setText("Show information >>"); frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100)); frame.pack(); } } }; toggle.addActionListener(actionListener); main.add(Box.createVerticalStrut(5)); main.add(info); main.add(Box.createVerticalStrut(5)); main.add(Box.createVerticalStrut(5)); main.add(actionButtons); main.add(Box.createVerticalStrut(10)); main.add(buttonBox); main.add(textBox); frame.add(main, BorderLayout.SOUTH); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setVisible(true); //initModels(); return frame; }
From source file:org.geopublishing.atlasStyler.swing.AtlasStylerGUI.java
/** * Creates a nre {@link JMenuBar} instance *///w w w . j a v a 2s. c o m private JMenuBar createMenuBar() { JMenuBar jMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu(AsSwingUtil.R("MenuBar.FileMenu")); jMenuBar.add(fileMenu); { // Import WIzard JMenuItem mi = new JMenuItem(new AbstractAction(AsSwingUtil.R("MenuBar.FileMenu.ImportWizard")) { @Override public void actionPerformed(ActionEvent e) { ImportWizard.showWizard(AtlasStylerGUI.this, AtlasStylerGUI.this); } }); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK, true)); fileMenu.add(mi); } fileMenu.add(SwingUtil.createChangeLog4JLevelJMenu()); /** * MenuItem to create a new language */ JMenuItem manageLanguageJMenuitem = new JMenuItem( new AbstractAction(ASUtil.R("TranslateSoftwareDialog.Title"), Icons.ICON_FLAGS_SMALL) { @Override public void actionPerformed(ActionEvent e) { String resPath = IOUtil .escapePath(System.getProperty("user.home") + File.separator + ".Geopublishing"); ResourceProviderManagerFrame manLanguagesFrame = new ResourceProviderManagerFrame( AtlasStylerGUI.this, true, AsSwingUtil.R("TranslateSoftwareDialog.Explanation.Html", resPath, SystemUtils.IS_OS_WINDOWS ? "bat" : "sh")); manLanguagesFrame.setRootPath(new File(resPath)); manLanguagesFrame.setTitle(ASUtil.R("TranslateSoftwareDialog.Title")); manLanguagesFrame.setPreferredSize(new Dimension(780, 450)); manLanguagesFrame.setVisible(true); } }); fileMenu.add(manageLanguageJMenuitem); AbstractAction optionsButton = new AbstractAction(AtlasStylerVector.R("Options.ButtonLabel")) { @Override public void actionPerformed(ActionEvent e) { new ASOptionsDialog(AtlasStylerGUI.this, AtlasStylerGUI.this); } }; fileMenu.add(optionsButton); { // Exit JMenuItem mi = new JMenuItem(new AbstractAction( GpCoreUtil.R("AtlasViewer.FileMenu.ExitMenuItem.exit_application"), Icons.ICON_EXIT_SMALL) { @Override public void actionPerformed(ActionEvent e) { exitAS(0); } }); fileMenu.add(mi); } return jMenuBar; }
From source file:org.intermine.install.swing.ProjectEditor.java
/** * Common initialisation: lays out the child components and wires up the necessary * event listeners. //from w ww . j a v a 2s .c o 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.isatools.isacreatorconfigurator.configui.DataEntryPanel.java
private JPanel createMenu() { JPanel topPanel = new JPanel(new GridLayout(1, 1)); topPanel.setBackground(UIHelper.BG_COLOR); topPanel.setBorder(null);// ww w . j a v a2 s .co m JMenuBar menu_container = new JMenuBar(); menu_container.setBorder(null); JMenu file = new JMenu("File"); JMenuItem save = new JMenuItem("Save"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { updateFieldOrder(); saveCurrentField(true, true); if (sourceFile == null) { createOutput(); } else { save(); } } catch (DataNotCompleteException dce) { showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE); } catch (Exception e1) { showMessagePane(e1.getMessage(), JOptionPane.ERROR_MESSAGE); } } }); JMenuItem createFile = new JMenuItem("Save As"); createFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { saveCurrentField(true, true); createOutput(); } catch (DataNotCompleteException dce) { showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE); } catch (IOException e1) { showMessagePane("IO error occurred when saving file!", JOptionPane.ERROR_MESSAGE); } catch (Exception e1) { showMessagePane(e1.getMessage(), JOptionPane.ERROR_MESSAGE); } } }); JMenuItem closeSession = new JMenuItem("Close session without saving"); closeSession.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tableFields.clear(); applicationContainer.setCurrentPage(applicationContainer.getMp()); } }); file.add(save); file.add(createFile); file.add(closeSession); JMenu mappingMenu = new JMenu("Mappings"); JMenuItem viewMappings = new JMenuItem("View Mappings", viewMappingsIcon); viewMappings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { public void run() { getApplicationContainer() .showJDialogAsSheet(new TableMappingViewer(getThis(), getTableTypeMapping())); } }); } }); mappingMenu.add(viewMappings); JMenu validation = new JMenu("Validation"); JMenuItem viewErrors = new JMenuItem("Show Validation Errors", viewMappingsIcon); viewErrors.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { public void run() { Validator validator = new Validator(); validateAll(validator); ValidationReport report = validator.getReport(); ConfigurationValidationUI validationUI = new ConfigurationValidationUI(tableFields.keySet(), report); validationUI.createGUI(); validationUI.setLocationRelativeTo(getApplicationContainer()); validationUI.setAlwaysOnTop(true); validationUI.setVisible(true); } }); } }); validation.add(viewErrors); JMenu helpMenu = new JMenu("Help"); JMenuItem about = new JMenuItem("About", aboutIcon); about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { public void run() { applicationContainer.setGlassPanelContents(aboutPanel); } }); } }); helpMenu.add(about); menu_container.add(file); menu_container.add(mappingMenu); menu_container.add(validation); menu_container.add(helpMenu); topPanel.add(menu_container); return topPanel; }
From source file:org.jab.docsearch.DocSearch.java
/** * Creates menu bar//from ww w.j a va 2s. 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; }
From source file:org.jajuk.ui.widgets.JajukJMenuBar.java
/** * Instantiates a new jajuk j menu bar./* w ww . j av a 2 s . co m*/ */ private JajukJMenuBar() { setAlignmentX(0.0f); // File menu file = new JMenu(Messages.getString("JajukJMenuBar.0")); jmiFileExit = new JMenuItem(ActionManager.getAction(JajukActions.EXIT)); file.add(jmiFileExit); // Properties menu properties = new JMenu(Messages.getString("JajukJMenuBar.5")); jmiNewProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_ADD)); jmiRemoveProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_REMOVE)); jmiActivateTags = new JMenuItem(ActionManager.getAction(EXTRA_TAGS_WIZARD)); properties.add(jmiNewProperty); properties.add(jmiRemoveProperty); properties.add(jmiActivateTags); // View menu views = new JMenu(Messages.getString("JajukJMenuBar.8")); jmiRestoreDefaultViews = new JMenuItem(ActionManager.getAction(VIEW_RESTORE_DEFAULTS)); jmiRestoreDefaultViewsAllPerpsectives = new JMenuItem( ActionManager.getAction(JajukActions.ALL_VIEW_RESTORE_DEFAULTS)); views.add(jmiRestoreDefaultViews); views.add(jmiRestoreDefaultViewsAllPerpsectives); views.addSeparator(); // Add the list of available views parsed in XML files at startup JMenu jmViews = new JMenu(Messages.getString("JajukJMenuBar.25")); for (final Class<? extends IView> view : ViewFactory.getKnownViews()) { JMenuItem jmi = null; try { jmi = new JMenuItem(view.newInstance().getDesc(), IconLoader.getIcon(JajukIcons.LOGO_FRAME)); } catch (Exception e1) { Log.error(e1); continue; } jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Simply add the new view in the current perspective PerspectiveAdapter current = (PerspectiveAdapter) PerspectiveManager.getCurrentPerspective(); IView newView = ViewFactory.createView(view, current, Math.abs(UtilSystem.getRandom().nextInt())); newView.initUI(); newView.setPopulated(); current.addDockable(newView); } }); jmViews.add(jmi); } views.add(jmViews); // Mode menu String modeText = Messages.getString("JajukJMenuBar.9"); mode = new JMenu(ActionUtil.strip(modeText)); jcbmiRepeat = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_MODE)); jcbmiRepeat.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT)); jcbmiRepeatAll = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_ALL_MODE)); jcbmiRepeatAll.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT_ALL)); jcbmiShuffle = new JCheckBoxMenuItem(ActionManager.getAction(SHUFFLE_MODE)); jcbmiShuffle.setSelected(Conf.getBoolean(Const.CONF_STATE_SHUFFLE)); jcbmiContinue = new JCheckBoxMenuItem(ActionManager.getAction(CONTINUE_MODE)); jcbmiContinue.setSelected(Conf.getBoolean(Const.CONF_STATE_CONTINUE)); jcbmiIntro = new JCheckBoxMenuItem(ActionManager.getAction(INTRO_MODE)); jcbmiIntro.setSelected(Conf.getBoolean(Const.CONF_STATE_INTRO)); jcbmiKaraoke = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.KARAOKE_MODE)); if (Conf.getBoolean(Const.CONF_BIT_PERFECT)) { jcbmiKaraoke.setEnabled(false); jcbmiKaraoke.setSelected(false); Conf.setProperty(Const.CONF_STATE_KARAOKE, Const.FALSE); } else { jcbmiKaraoke.setSelected(Conf.getBoolean(Const.CONF_STATE_KARAOKE)); } mode.add(jcbmiRepeat); mode.add(jcbmiRepeatAll); mode.add(jcbmiShuffle); mode.add(jcbmiContinue); mode.add(jcbmiIntro); mode.add(jcbmiKaraoke); // Smart Menu smart = new JMenu(Messages.getString("JajukJMenuBar.29")); jmiShuffle = new SizedJMenuItem(ActionManager.getAction(JajukActions.SHUFFLE_GLOBAL)); jmiBestof = new SizedJMenuItem(ActionManager.getAction(JajukActions.BEST_OF)); jmiNovelties = new SizedJMenuItem(ActionManager.getAction(JajukActions.NOVELTIES)); jmiFinishAlbum = new SizedJMenuItem(ActionManager.getAction(JajukActions.FINISH_ALBUM)); smart.add(jmiShuffle); smart.add(jmiBestof); smart.add(jmiNovelties); smart.add(jmiFinishAlbum); // Tools Menu tools = new JMenu(Messages.getString("JajukJMenuBar.28")); jmiduplicateFinder = new JMenuItem(ActionManager.getAction(JajukActions.FIND_DUPLICATE_FILES)); jmialarmClock = new JMenuItem(ActionManager.getAction(JajukActions.ALARM_CLOCK)); jmiprepareParty = new JMenuItem(ActionManager.getAction(JajukActions.PREPARE_PARTY)); tools.add(jmiduplicateFinder); tools.add(jmialarmClock); tools.add(jmiprepareParty); // tools.addSeparator(); // Configuration menu configuration = new JMenu(Messages.getString("JajukJMenuBar.21")); jmiDJ = new JMenuItem(ActionManager.getAction(CONFIGURE_DJS)); // Overwrite default icon jmiDJ.setIcon(IconLoader.getIcon(JajukIcons.DIGITAL_DJ_16X16)); jmiAmbience = new JMenuItem(ActionManager.getAction(CONFIGURE_AMBIENCES)); jmiWizard = new JMenuItem(ActionManager.getAction(SIMPLE_DEVICE_WIZARD)); jmiOptions = new JMenuItem(ActionManager.getAction(OPTIONS)); jmiUnmounted = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.UNMOUNTED)); jmiUnmounted.setSelected(Conf.getBoolean(Const.CONF_OPTIONS_HIDE_UNMOUNTED)); jmiUnmounted.putClientProperty(Const.DETAIL_ORIGIN, jmiUnmounted); jcbShowPopups = new JCheckBoxMenuItem(Messages.getString("ParameterView.228")); jcbShowPopups.setSelected(Conf.getBoolean(Const.CONF_SHOW_POPUPS)); jcbShowPopups.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Conf.setProperty(Const.CONF_SHOW_POPUPS, Boolean.toString(jcbShowPopups.isSelected())); // force parameter view to take this into account ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE)); } }); jcbNoneInternetAccess = new JCheckBoxMenuItem(Messages.getString("ParameterView.264")); jcbNoneInternetAccess.setToolTipText(Messages.getString("ParameterView.265")); jcbNoneInternetAccess.setSelected(Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)); jcbNoneInternetAccess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Conf.setProperty(Const.CONF_NETWORK_NONE_INTERNET_ACCESS, Boolean.toString(jcbNoneInternetAccess.isSelected())); // force parameter view to take this into account ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE)); } }); configuration.add(jmiUnmounted); configuration.add(jcbShowPopups); configuration.add(jcbNoneInternetAccess); configuration.addSeparator(); configuration.add(jmiDJ); configuration.add(jmiAmbience); configuration.add(jmiWizard); configuration.add(jmiOptions); // Help menu String helpText = Messages.getString("JajukJMenuBar.14"); help = new JMenu(ActionUtil.strip(helpText)); jmiHelp = new JMenuItem(ActionManager.getAction(HELP_REQUIRED)); jmiDonate = new JMenuItem(ActionManager.getAction(SHOW_DONATE)); jmiAbout = new JMenuItem(ActionManager.getAction(SHOW_ABOUT)); jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES)); jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES)); jmiCheckforUpdates = new JMenuItem(ActionManager.getAction(JajukActions.CHECK_FOR_UPDATES)); jmiTipOfTheDay = new JMenuItem(ActionManager.getAction(TIP_OF_THE_DAY)); help.add(jmiHelp); help.add(jmiTipOfTheDay); // Install this action only if Desktop class is supported, it is used to // open default mail client if (UtilSystem.isBrowserSupported()) { jmiQualityAgent = new JMenuItem(ActionManager.getAction(QUALITY)); help.add(jmiQualityAgent); } help.add(jmiTraces); help.add(jmiCheckforUpdates); help.add(jmiDonate); help.add(jmiAbout); mainmenu = new JMenuBar(); mainmenu.add(file); mainmenu.add(views); mainmenu.add(properties); mainmenu.add(mode); mainmenu.add(smart); mainmenu.add(tools); mainmenu.add(configuration); mainmenu.add(help); // Apply mnemonics (Alt + first char of the menu keystroke) applyMnemonics(); if (SessionService.isTestMode()) { jbGC = new JajukButton(ActionManager.getAction(JajukActions.GC)); } jbSlim = new JajukButton(ActionManager.getAction(JajukActions.SLIM_JAJUK)); jbFull = new JajukButton(ActionManager.getAction(JajukActions.FULLSCREEN_JAJUK)); JMenuBar eastmenu = new JMenuBar(); // only show GC-button in test-mode if (SessionService.isTestMode()) { eastmenu.add(jbGC); } eastmenu.add(jbSlim); eastmenu.add(jbFull); setLayout(new BorderLayout()); add(mainmenu, BorderLayout.WEST); add(eastmenu, BorderLayout.EAST); // Check for new release and display the icon if a new release is available SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { UpgradeManager.checkForUpdate(); return null; } @Override public void done() { // add the new release label if required if (UpgradeManager.getNewVersionName() != null) { jlUpdate = new JLabel(" ", IconLoader.getIcon(JajukIcons.UPDATE_MANAGER), SwingConstants.RIGHT); String newRelease = UpgradeManager.getNewVersionName(); if (newRelease != null) { jlUpdate.setToolTipText(Messages.getString("UpdateManager.0") + newRelease + Messages.getString("UpdateManager.1")); } add(Box.createHorizontalGlue()); add(jlUpdate); } } }; // Search online for upgrade if the option is set and if the none Internet // access option is not set if (Conf.getBoolean(Const.CONF_CHECK_FOR_UPDATE) && !Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)) { sw.execute(); } ObservationManager.register(this); }
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); bar.add(containerMenu);/*w w w.j a v a2 s . c o m*/ 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(); {/*from w ww . java2 s. co 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.smack.JCurlSmackClient.java
private JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); final String[] xmppMenuActionNames = { "xmppAccount", "[]xmppSession", "[]xmppChat", "xmppPreferences", "---", "[]xmppRoster", "---", "quit" }; final JMenu menu = gui.createMenu("xmppMenu", xmppMenuActionNames); miRoster = (JCheckBoxMenuItem) menu.getMenuComponent(5); menuBar.add(menu); final String[] helpMenuActionNames = { "showAboutBox" }; menuBar.add(gui.createMenu("helpMenu", helpMenuActionNames)); return menuBar; }
From source file:org.jcurl.demo.tactics.JCurlShotPlanner.java
private JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); final String[] fileMenuActionNames = { /*"fileClear",*/ "fileNewDoc", "fileHammy", "---", "fileOpen", "fileOpenURL", "---", "fileReset", "fileSave", "fileSaveAs", "fileSaveCopyAs", "---", "fileExportPng", "fileExportSvg", "---", "quit" }; menuBar.add(gui.createMenu("fileMenu", fileMenuActionNames)); final String[] editMenuActionNames = { "editUndo", "editRedo", "---", "editOut", "editHome", "---", "editProperties", "---", "editPreferences" }; menuBar.add(gui.createMenu("editMenu", editMenuActionNames)); final String[] viewMenuActionNames = { "viewHouse", "view12Foot", "viewComplete", "viewActive", "---", "viewZoomIn", "viewZoomOut", "---", "viewPanNorth", "viewPanSouth", "viewPanEast", "viewPanWest" }; menuBar.add(gui.createMenu("viewMenu", viewMenuActionNames)); final String[] helpMenuActionNames = { "showAboutBox", "helpDumpProperties" }; menuBar.add(gui.createMenu("helpMenu", helpMenuActionNames)); return menuBar; }