List of usage examples for javax.swing JMenu add
public JMenuItem add(Action a)
From source file:core.PlanC.java
private static void configureWorkMenuBar() { menuBar = new JMenuBar(); // --------------------------------------------------------------- // app menu - Only master user // --------------------------------------------------------------- JMenu menu = new JMenu(TStringUtils.getBundleString("about.app.id")); // MenuActionFactory maf = null; // maf = new MenuActionFactory(SystemVars.class); // menu.add(maf); // maf = new MenuActionFactory(TConnectionDialog.class); // maf.setDimension(MenuActionFactory.PACK_DIMMENTION); // menu.add(maf); // maf = new MenuActionFactory(TDriverDialog.class); // maf.setDimension(MenuActionFactory.PACK_DIMMENTION); // menu.add(maf); // menu.add(new LoadView()); // menu.add(new SaveView()); // menu.add(new UpdateManifestView()); // menuBar.add(menu); // apend plugin actions. menu = new JMenu("Extensions"); Vector<String> ip = PluginManager.getInstalledPlungin(); for (String pic : ip) { String act = PluginManager.getPluginProperty(pic, "plugin.type"); if (act.equals(Plugin.TYPE_UI)) { Object obj = PluginManager.getPlugin(pic).executePlugin(null); if (obj instanceof TAbstractAction) { menu.add((TAbstractAction) obj); }/*from ww w .j a va2 s . c om*/ // TODO: 180116: is necesary grant plugins more control over jmenubar. !!!! if (obj instanceof Vector) { Vector v = (Vector) obj; // for plancplugin, every action in vector is a main menu if (pic.equals("SLEPlanC")) { for (Object jc : v) { menuBar.add((JComponent) jc); } } else { JMenu jm = new JMenu(PluginManager.getPluginProperty(pic, "plugin.caption")); for (Object aa : v) { jm.add((AbstractAction) aa); } menu.add(jm); } } } } if (menu.getMenuComponentCount() > 0) { menuBar.add(menu); } // --------------------------------------------------------------- // Help // --------------------------------------------------------------- menu = new JMenu(TStringUtils.getBundleString("main.menuitem.help")); // g7.add(new Help()); // menu.add(new UpdateManifestView()); // menu.add(new JSeparator(JSeparator.HORIZONTAL)); // menu.add(new DockingAction(Wellcome.class)); // menu.add(new DockingAction(HelpBrowser.class)); // HelpRecorderAction act = new HelpRecorderAction(); // act.setEnabled(SLESession.getUserFieldValue("t_ususer_id").equals("*master")); // g7.add(act); // maf = new MenuActionFactory(AuditLog.class); // maf.setDimension(MenuActionFactory.LARGE_DIMMENTION); // menu.add(maf); // maf = new MenuActionFactory(References.class); // maf.setDimension(MenuActionFactory.LARGE_DIMMENTION); // menu.add(maf); menu.add(new About()); menuBar.add(menu); // --------------------------------------------------------------- // user // --------------------------------------------------------------- // 171201 1.24: Mierdaaa ya es diciembre y yo pelandooooooooo otro aooo !?!?! user options moved to // plancselector // menu = new JMenu((String) Session.getUserName()); // menu.setIcon(TResourceUtils.getSmallIcon("user_user")); // menu.add(new PChangePasswordAction()); // menu.add(new SignOut()); // menu.add(new JSeparator(JSeparator.HORIZONTAL)); // menu.add(new Exit()); // menuBar.add(menu); // --------------------------------------------------------------- // selector // --------------------------------------------------------------- final PlanCSelector pcs = new PlanCSelector(); menuBar.add(pcs.getBreadcrumb()); frame.setJMenuBar(menuBar); }
From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java
@Override protected JMenu buildResultsMenu() { JMenu resultsMenu = new JMenu("Results"); resultsMenu.setMnemonic('r'); JMenuItem racsItem = new JMenuItem("Category acceptability indices", ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_RANKACCEPTABILITIES)); racsItem.setMnemonic('r'); racsItem.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { Focuser.focus(tree, treeModel, treeModel.getCatAccNode()); }/* w w w .j a v a 2 s.c o m*/ }); resultsMenu.add(racsItem); return resultsMenu; }
From source file:livecanvas.mesheditor.MeshEditor.java
public JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu, subMenu; JMenuItem menuItem;// w w w. jav a 2s.c o m menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); menu.add(menuItem = Utils.createMenuItem("New", NEW, KeyEvent.VK_N, "ctrl N", this)); menu.add(menuItem = Utils.createMenuItem("Open...", OPEN, KeyEvent.VK_O, "ctrl O", this)); menu.add(menuItem = Utils.createMenuItem("Save", SAVE, KeyEvent.VK_S, "ctrl S", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Exit", EXIT, KeyEvent.VK_X, "", this)); menuBar.add(menu); menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); menu.add(menuItem = Utils.createMenuItem("Undo", UNDO, KeyEvent.VK_U, "ctrl Z", this)); menu.add(menuItem = Utils.createMenuItem("Redo", REDO, KeyEvent.VK_R, "ctrl Y", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Cut", CUT, KeyEvent.VK_T, "ctrl X", this)); menu.add(menuItem = Utils.createMenuItem("Copy", COPY, KeyEvent.VK_C, "ctrl C", this)); menu.add(menuItem = Utils.createMenuItem("Paste", PASTE, KeyEvent.VK_P, "ctrl V", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Select All", SELECT_ALL, KeyEvent.VK_A, "ctrl A", this)); menu.add(menuItem = Utils.createMenuItem("Invert Selection", INVERT_SELECTION, 0, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Settings...", SETTINGS, KeyEvent.VK_S, "", this)); menuBar.add(menu); menu = new JMenu("Tools"); menu.setMnemonic(KeyEvent.VK_T); menu.add(menuItem = Utils.createMenuItem("Brush", TOOLS_BRUSH, KeyEvent.VK_B, "B", this)); menu.add(menuItem = Utils.createMenuItem("Pencil", TOOLS_PEN, KeyEvent.VK_N, "N", this)); menu.add(menuItem = Utils.createMenuItem("Magic Wand", TOOLS_MAGICWAND, KeyEvent.VK_W, "W", this)); menu.add(menuItem = Utils.createMenuItem("Set Control Points", TOOLS_SETCONTROLPOINTS, KeyEvent.VK_C, "C", this)); menu.add(menuItem = Utils.createMenuItem("Pointer", TOOLS_POINTER, KeyEvent.VK_P, "P", this)); menu.add(menuItem = Utils.createMenuItem("Pan / Zoom", TOOLS_PANZOOM, KeyEvent.VK_Z, "Z", this)); menuBar.add(menu); menu = new JMenu("Layers"); menu.setMnemonic(KeyEvent.VK_L); menu.add(menuItem = Utils.createMenuItem("Add Layer...", ADD_LAYER, KeyEvent.VK_A, "", this)); menu.add(menuItem = Utils.createMenuItem("Remove", REMOVE_LAYER, KeyEvent.VK_R, "", this)); menu.add(menuItem = Utils.createMenuItem("Duplicate", DUPLICATE_LAYER, KeyEvent.VK_C, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Move Up", MOVEUP_LAYER, KeyEvent.VK_U, "", this)); menu.add(menuItem = Utils.createMenuItem("Move Down", MOVEDOWN_LAYER, KeyEvent.VK_D, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Reparent Layer...", REPARENT_LAYER, KeyEvent.VK_R, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Group Layers", GROUP_LAYERS, KeyEvent.VK_G, "", this)); menu.add(menuItem = Utils.createMenuItem("Ungroup Layer", UNGROUP_LAYER, KeyEvent.VK_N, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Join Layers", JOIN_LAYERS, KeyEvent.VK_J, "", this)); menu.add(menuItem = Utils.createMenuItem("Intersect", INTERSECT_LAYERS, KeyEvent.VK_I, "", this)); menu.add(menuItem = Utils.createMenuItem("Subtract", SUBTRACT_LAYERS, KeyEvent.VK_S, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Rename...", RENAME_LAYER, KeyEvent.VK_E, "", this)); menu.addSeparator(); subMenu = new JMenu("Background Reference"); subMenu.add(menuItem = Utils.createMenuItem("Set...", BGREF_SET, KeyEvent.VK_S, "", this)); subMenu.add(menuItem = Utils.createMenuItem("Remove", BGREF_REMOVE, KeyEvent.VK_R, "", this)); menu.add(subMenu); menuBar.add(menu); menu.addSeparator(); menu.add(menuItem = Utils.createMenuItem("Create Mesh Grid", CREATE_MESHGRID, KeyEvent.VK_M, "", this)); menu.addSeparator(); menu.add(menuItem = Utils.createCheckBoxMenuItem("See Through", SEE_THROUGH, KeyEvent.VK_T, "", this)); menuItem.setSelected(true); menu.add(menuItem = Utils.createCheckBoxMenuItem("Show Mesh", SHOW_MESH, KeyEvent.VK_M, "", this)); menuItem.setSelected(true); return menuBar; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private JMenu createEditMenu() { JMenu edit_menu = new JMenu("Edit"); edit_menu.setMnemonic(KeyEvent.VK_E); edit_menu.add(theActionManager.get("undo")); edit_menu.add(theActionManager.get("redo")); edit_menu.addSeparator();/*from w ww . j a v a2 s . c o m*/ edit_menu.add(theActionManager.get("cut")); edit_menu.add(theActionManager.get("copy")); edit_menu.add(theActionManager.get("delete")); edit_menu.add(theActionManager.get("screenshot")); edit_menu.addSeparator(); edit_menu.add(theActionManager.get("selectall")); edit_menu.add(theActionManager.get("selectnone")); edit_menu.addSeparator(); edit_menu.add(theActionManager.get("enlarge")); edit_menu.add(theActionManager.get("resetsize")); edit_menu.add(theActionManager.get("shrink")); edit_menu.addSeparator(); edit_menu.add(theActionManager.get("group")); edit_menu.add(theActionManager.get("ungroup")); edit_menu.addSeparator(); edit_menu.add(theActionManager.get("placestructures")); return edit_menu; }
From source file:fedroot.dacs.swingdemo.DacsSingleFrameApplication.java
private JMenu createMenu(String menuName, String[] actionNames) { JMenu menu = new JMenu(); menu.setName(menuName);//w ww . j a v a 2 s.co m for (String actionName : actionNames) { JMenuItem menuItem = new JMenuItem(); menuItem.setAction(actionMap().get(actionName)); menu.add(menuItem); } return menu; }
From source file:com.intuit.tank.proxy.ProxyApp.java
@SuppressWarnings("serial") public JMenuBar createMenu() { JMenuBar ret = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu sessionMenu = new JMenu("Session"); ret.add(fileMenu);/* w w w . j a va2 s. co m*/ ret.add(sessionMenu); fileMenu.add(getMenuItem(openAction)); fileMenu.add(getMenuItem(saveAction)); fileMenu.addSeparator(); fileMenu.add(getMenuItem(filterAction)); fileMenu.add(getMenuItem(settingsAction)); fileMenu.addSeparator(); AbstractAction quitAction = new AbstractAction("Quit") { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }; quitAction.putValue(javax.swing.Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask)); quitAction.putValue(javax.swing.Action.MNEMONIC_KEY, KeyEvent.VK_Q); fileMenu.add(new JMenuItem(quitAction)); sessionMenu.add(getMenuItem(startAction)); sessionMenu.add(getMenuItem(stopAction)); sessionMenu.add(getMenuItem(pauseAction)); sessionMenu.addSeparator(); sessionMenu.add(getMenuItem(showHostsAction)); return ret; }
From source file:JXTransformer.java
public TransformerDemo() { super("Transformer demo"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu lafMenu = new JMenu("LaF"); JMenuItem winLaf = new JMenuItem("Windows LaF"); lafMenu.add(winLaf); winLaf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLaf("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); }//from w w w . j ava 2 s . c om }); JMenuItem motifLaf = new JMenuItem("Motif LaF"); lafMenu.add(motifLaf); motifLaf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLaf("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } }); bar.add(lafMenu); JMenuItem metalLaf = new JMenuItem("Metal LaF"); lafMenu.add(metalLaf); metalLaf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLaf("javax.swing.plaf.metal.MetalLookAndFeel"); } }); JMenu settingsMenu = new JMenu("Settings"); settingsMenu.setMnemonic(KeyEvent.VK_S); JMenuItem item = new JMenuItem("Reset sliders", KeyEvent.VK_R); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK)); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rotationSlider.setValue(0); scalingSlider.setValue(100); shearingSlider.setValue(0); } }); settingsMenu.add(item); bar.add(settingsMenu); setJMenuBar(bar); JPanel panel = new JPanel(new BorderLayout()); panel.add(createDemoPanel()); panel.add(createStressTestPanel(), BorderLayout.EAST); add(new JScrollPane(panel)); add(new JScrollPane(createToolPanel()), BorderLayout.SOUTH); pack(); }
From source file:com.frostwire.gui.library.LibraryDeviceTableMediator.java
private JMenu createSearchSubMenu(LibraryDeviceTableDataLine dl) { JMenu menu = new SkinMenu(I18n.tr("Search")); if (dl != null) { String str = buildQueryString(dl.getInitializeObject()); String keywords = QueryUtils.createQueryString(str); if (keywords.length() > 0) menu.add(new SkinMenuItem(new SearchAction(keywords))); }/*from w ww .java2 s . co m*/ if (menu.getItemCount() == 0) menu.setEnabled(false); return menu; }
From source file:com.AandR.beans.plotting.LinePlotPanel.LinePlotPanel.java
private JMenu createExportMenu() { JMenu menu = new JMenu("Export"); menu.add(createMenuItem("PNG", ACTION_EXPORT_PNG)); return menu;/*from www .ja v a 2 s .c o m*/ }
From source file:IntroExample.java
public IntroExample() { JMenu fileMenu = new JMenu("File"); JMenu editMenu = new JMenu("Edit"); JMenu otherMenu = new JMenu("Other"); JMenu subMenu = new JMenu("SubMenu"); JMenu subMenu2 = new JMenu("SubMenu2"); // Assemble the File menus with mnemonics ActionListener printListener = new ActionListener() { public void actionPerformed(ActionEvent event) { System.out.println("Menu item [" + event.getActionCommand() + "] was pressed."); }/*from w w w .j a va 2s .c o m*/ }; for (int i = 0; i < fileItems.length; i++) { JMenuItem item = new JMenuItem(fileItems[i], fileShortcuts[i]); item.addActionListener(printListener); fileMenu.add(item); } // Assemble the File menus with keyboard accelerators for (int i = 0; i < editItems.length; i++) { JMenuItem item = new JMenuItem(editItems[i]); item.setAccelerator(KeyStroke.getKeyStroke(editShortcuts[i], Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); item.addActionListener(printListener); editMenu.add(item); } // Insert a separator in the Edit Menu in Position 1 after "Undo" editMenu.insertSeparator(1); // Assemble the submenus of the Other Menu JMenuItem item; subMenu2.add(item = new JMenuItem("Extra 2")); item.addActionListener(printListener); subMenu.add(item = new JMenuItem("Extra 1")); item.addActionListener(printListener); subMenu.add(subMenu2); // Assemble the Other Menu itself otherMenu.add(subMenu); otherMenu.add(item = new JCheckBoxMenuItem("Check Me")); item.addActionListener(printListener); otherMenu.addSeparator(); ButtonGroup buttonGroup = new ButtonGroup(); otherMenu.add(item = new JRadioButtonMenuItem("Radio 1")); item.addActionListener(printListener); buttonGroup.add(item); otherMenu.add(item = new JRadioButtonMenuItem("Radio 2")); item.addActionListener(printListener); buttonGroup.add(item); otherMenu.addSeparator(); otherMenu.add(item = new JMenuItem("Potted Plant", new ImageIcon("image.gif"))); item.addActionListener(printListener); // Finally, add all the menus to the menu bar add(fileMenu); add(editMenu); add(otherMenu); }