Java 类javax.swing.JMenu 实例源码

项目:incubator-netbeans    文件:OutputTab.java   
private void addFoldingActionsToPopUpMenu(JPopupMenu menu,
        List<TabAction> activeActions) {
    JMenu submenu = new JMenu(NbBundle.getMessage(
            OutputTab.class, "LBL_OutputFolds"));                   //NOI18N
    for (ACTION a : popUpFoldItems) {
        if (a == null) {
            submenu.addSeparator();
        } else {
            TabAction ta = action(a);
            activeActions.add(ta);
            submenu.add(new JMenuItem(ta));
        }
    }
    menu.addSeparator();
    menu.add(submenu);
}
项目:JavaGraph    文件:AspectJGraph.java   
@Override
public JMenu createPopupMenu(Point atPoint) {
    MyJMenu result = new MyJMenu("Popup");
    switch (getGraphRole()) {
    case HOST:
        result.add(getActions().getApplyMatchAction());
        result.addSeparator();
        break;
    default:
        // do nothing
    }
    Action editAction;
    if (isForState()) {
        editAction = getActions().getEditStateAction();
    } else {
        editAction = getActions().getEditAction(ResourceKind.toResource(getGraphRole()));
    }
    result.add(editAction);
    result.addSubmenu(createEditMenu(atPoint));
    result.addSubmenu(super.createPopupMenu(atPoint));
    return result;
}
项目:incubator-netbeans    文件:WorkspaceSwitchAction.java   
/** Initializes listeners atc to the given workspace */
void attachWorkspace(
    Workspace workspace, Workspace[] currentDeskRef, Hashtable workspace2Menu, Hashtable menu2Workspace,
    Hashtable workspace2Listener, JMenu menu
) {
    // bugfix #6116 - change from getName() to getDisplayName()
    JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem();
    Mnemonics.setLocalizedText(menuItem, workspace.getDisplayName());
    HelpCtx.setHelpIDString(menuItem, WorkspaceSwitchAction.class.getName());

    ActionListener listener = createActionListener(menuItem, currentDeskRef, menu2Workspace, workspace2Menu);
    menuItem.addActionListener(listener);
    menu2Workspace.put(listener, workspace);
    workspace2Listener.put(workspace, listener);
    workspace2Menu.put(workspace, menuItem);
    workspace.addPropertyChangeListener(createNameListener(menuItem));
    menu.add(menuItem);
}
项目:freecol    文件:MapEditorMenuBar.java   
private void buildGameMenu() {
    // --> Game
    JMenu menu = Utility.localizedMenu("menuBar.game");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_G);

    menu.add(getMenuItem(NewAction.id));
    menu.add(getMenuItem(NewEmptyMapAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(OpenAction.id));
    menu.add(getMenuItem(SaveAction.id));
    menu.add(getMenuItem(StartMapAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(PreferencesAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(ShowMainAction.id));
    menu.add(getMenuItem(QuitAction.id));

    add(menu);
}
项目:Cognizant-Intelligent-Test-Scripter    文件:AppMenuBar.java   
private JMenu createWindowMenu() {
    JMenu window = new JMenu("Window");
    window.setMnemonic('W');

    window.add(
            withMnemonics(
                    withEmptyIcon(
                            withShortCut(Utils.createMenuItem("Test Design", sActionListener))), 'T'));

    window.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("Test Execution", sActionListener)), 'E'));
    window.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("Dashboard", sActionListener)), 'D'));

    window.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("AdjustUI", sActionListener)), 'A'));

    return window;
}
项目:the-one-mdonnyk    文件:SimMenuBar.java   
private void init() {
    JMenu pfMenu = new JMenu("Playfield graphics");
    JMenu help = new JMenu("Help");
    Settings settings = new Settings(UNDERLAY_NS);
    if (settings.contains("fileName")) {
        // create underlay image menu item only if filename is specified 
        enableBgImage = createCheckItem(pfMenu,"Show underlay image",false);
    }
    enableNodeName = createCheckItem(pfMenu, "Show node name string",true);
    enableNodeCoverage = createCheckItem(pfMenu, 
            "Show node radio coverage", true);
    enableNodeConnections = createCheckItem(pfMenu,
            "Show node's connections", true);
    enableMapGraphic = createCheckItem(pfMenu,"Show map graphic",true);
    autoClearOverlay = createCheckItem(pfMenu, "Autoclear overlay",true);
    clearOverlay = createMenuItem(pfMenu,"Clear overlays now");
    about = createMenuItem(help,"about");
    this.add(pfMenu);
    this.add(Box.createHorizontalGlue());
    this.add(help);
}
项目:AgentWorkbench    文件:ProjectsLoaded.java   
/**
 * Create's the Window=>MenuItems depending on the open projects 
 */
private void setProjectMenuItems() {

    boolean setFontBold = true;

    JMenu WindowMenu = Application.getMainWindow().getJMenuMainWindow();
    WindowMenu.removeAll();
    if (this.count()==0 ){
        WindowMenu.add( new JMenuItmen_Window( Language.translate("Kein Projekt geöffnet !"), -1, setFontBold ) );
    } else {
        for(int i=0; i<this.count(); i++) {
            String ProjectName = this.getProjectsOpen().get(i).getProjectName();
            if ( ProjectName.equalsIgnoreCase( Application.getProjectFocused().getProjectName() ) ) 
                setFontBold = true;
            else 
                setFontBold = false;
            WindowMenu.add( new JMenuItmen_Window( ProjectName, i, setFontBold) );
        }       
    }
}
项目:Logisim    文件:MenuSimulate.java   
private void recreateStateMenu(JMenu menu, ArrayList<CircuitStateMenuItem> items, int code) {
    menu.removeAll();
    menu.setEnabled(items.size() > 0);
    boolean first = true;
    int mask = getToolkit().getMenuShortcutKeyMask();
    for (int i = items.size() - 1; i >= 0; i--) {
        JMenuItem item = items.get(i);
        menu.add(item);
        if (first) {
            item.setAccelerator(KeyStroke.getKeyStroke(code, mask));
            first = false;
        } else {
            item.setAccelerator(null);
        }
    }
}
项目:Cognizant-Intelligent-Test-Scripter    文件:ProjectTree.java   
protected final void init() {
    add(addScenario = create("Add Scenario", Keystroke.NEW));
    add(renameScenario = create("Rename Scenario", Keystroke.RENAME));
    add(deleteScenario = create("Delete Scenario", Keystroke.DELETE));
    addSeparator();
    add(addTestCase = create("Add TestCase", Keystroke.NEW));
    add(renameTestCase = create("Rename TestCase", Keystroke.RENAME));
    add(deleteTestCase = create("Delete TestCase", Keystroke.DELETE));

    addSeparator();
    JMenu menu = new JMenu("Export As");
    menu.add(create("Manual Testcase", null));
    add(menu);
    add(toggleReusable = create("Make As Reusable/TestCase", null));
    toggleReusable.setText("Make As Reusable");
    addSeparator();
    setCCP();
    addSeparator();
    add(impactAnalysis = create("Get Impacted TestCases", null));
    add(getCmdSyntax = create("Get CmdLine Syntax", null));
    addSeparator();
    add(sort = create("Sort", null));
    addSeparator();
    add(create("Details", Keystroke.ALTENTER));
    sort.setIcon(Canvas.EmptyIcon);
}
项目:incubator-netbeans    文件:NbEditorKit.java   
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
    String menuText = org.openide.util.NbBundle.getBundle (NbEditorKit.class).
        getString("Menu/View/CodeFolds");
    JMenu menu = new JMenu(menuText);
    Mnemonics.setLocalizedText(menu, menuText);
    setAddSeparatorBeforeNextAction(false);
    addAction(target, menu, BaseKit.collapseFoldAction);
    addAction(target, menu, BaseKit.expandFoldAction);
    setAddSeparatorBeforeNextAction(true);
    addAction(target, menu, BaseKit.collapseAllFoldsAction);
    addAction(target, menu, BaseKit.expandAllFoldsAction);
    // this is a hack, which assumes a certain action name from editor.fold.ui
    // if the action does not exist, nothing will be added to the menu.
    addAction(target, menu, "collapse-fold-tree"); // NOI18N
    addAction(target, menu, "expand-fold-tree"); // NOI18N
    // By default add separator before next actions (can be overriden if unwanted)
    setAddSeparatorBeforeNextAction(true);
    if (target != null) addAdditionalItems(target, menu);
    return menu;
}
项目:QN-ACTR-Release    文件:FuzzyKSingleClusterScatter.java   
public KMeanScatterPopupMenu() {
    restore = new JMenuItem("Original view");
    saveAs = new JMenuItem("Save as...");
    clusters = new JMenu("Cluster");
    printClusterInfo = new JMenuItem("Save info...");
    point = new JMenu("Point size");
    for (int i = 0; i < 3; i++) {
        JMenuItem m = new JMenuItem();
        m.setAction(commonActionSize);
        m.setText("Size " + Integer.toString((i + 1)));
        point.add(m);
    }
    this.add(restore);
    this.addSeparator();
    this.add(point);
    this.addSeparator();
    this.add(saveAs);
    this.addSeparator();
    this.add(printClusterInfo);
    this.addSeparator();
    this.add(clusters);
    addListeners();

}
项目:incubator-netbeans    文件:DebuggingActionsProvider.java   
public JMenuItem getPopupPresenter() {
    JMenu displayAsPopup = new JMenu();
    Mnemonics.setLocalizedText(displayAsPopup, NbBundle.getMessage(DebuggingActionsProvider.class, "CTL_Session_Popup_Language"));

    String [] languages = session.getSupportedLanguages();
    String currentLanguage = session.getCurrentLanguage();
    for (int i = 0; i < languages.length; i++) {
        final String language = languages[i];
        JRadioButtonMenuItem langItem = new JRadioButtonMenuItem(new AbstractAction(language) {
            public void actionPerformed(ActionEvent e) {
                session.setCurrentLanguage(language);
            }
        });
        if (currentLanguage.equals(language)) langItem.setSelected(true);
        displayAsPopup.add(langItem);
    }
    return displayAsPopup;
}
项目:incubator-netbeans    文件:LanguagesGenerateFoldPopupAction.java   
private void addFoldTypes (JTextComponent target, JMenu menu, Language language, Set expands) {
    List<Feature> features = language.getFeatureList ().getFeatures (LanguagesFoldManager.FOLD);
    Iterator<Feature> it = features.iterator ();
    while (it.hasNext ()) {
        Feature fold = it.next ();
        String expand = LocalizationSupport.localize (language, (String) fold.getValue ("expand_type_action_name"));
        if (expand == null) continue;
        if (expands.contains (expand))
            continue;
        expands.add (expand);
        String collapse = LocalizationSupport.localize (language, (String) fold.getValue ("collapse_type_action_name"));
        if (collapse == null) continue;
        addAction (target, menu, EXPAND_PREFIX + expand);
        addAction (target, menu, COLLAPSE_PREFIX + collapse);
        setAddSeparatorBeforeNextAction (true);
    }
}
项目:QN-ACTR-Release    文件:KFuzzyScatter.java   
public KMeanScatterPopupMenu() {
    restore = new JMenuItem("Original view");
    saveAs = new JMenuItem("Save as...");
    //clusters = new JMenu("Clusters");
    printClusterInfo = new JMenuItem("Save info...");
    point = new JMenu("Point size");
    for (int i = 0; i < 5; i++) {
        JMenuItem m = new JMenuItem();
        m.setAction(commonActionSize);
        m.setText("Size " + Integer.toString((i + 1)));
        point.add(m);
    }
    this.add(restore);
    this.addSeparator();
    this.add(point);
    this.addSeparator();
    this.add(saveAs);
    this.addSeparator();
    this.add(printClusterInfo);
    //this.addSeparator();
    //this.add(clusters);
    addListeners();

}
项目:Java_GestionProjet    文件:ActionClickDroit.java   
@Override
public void mouseClicked(MouseEvent e) {

    FenetreGestionDeProjet fenetre = FenetreGestionDeProjet.getInstance();

    // TODO Auto-generated method stub
    if (e.getButton() == MouseEvent.BUTTON3) {
        //System.out.println("modification et suppression");
        JMenu contextMenu = new JMenu();
        JMenuItem modifie = new JMenuItem("Modifier");
        JMenuItem supprime = new JMenuItem("Supprimer");
        contextMenu.add(modifie);
        contextMenu.add(supprime);
        contextMenu.setMenuLocation(e.getX(),e.getY());

        fenetre.add(contextMenu);

        contextMenu.setEnabled(true);
        contextMenu.setVisible(true);

        contextMenu.setPopupMenuVisible(true);
    }
}
项目:KernelHive    文件:MainFrame.java   
private void initProjectMenu() {
    mnProject = new JMenu(BUNDLE.getString("MainFrame.mnProject.text"));
    mnProject.setMnemonic(KeyEvent.VK_P);
    mainMenuBar.add(mnProject);

    mntmProperties = new JMenuItem(
            BUNDLE.getString("MainFrame.mntmProperties.text"));
    mntmProperties
            .setIcon(new ImageIcon(
                    MainFrame.class
                            .getResource("/toolbarButtonGraphics/general/Properties16.gif")));
    mntmProperties.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {
            controller.showProjectProperties();
        }
    });
    mnProject.add(mntmProperties);
}
项目:JavaGraph    文件:MyJMenu.java   
/** 
 * Adds to a given menu all the items of another menu.
 * The submenu may be {@code null}, in which case nothing is added 
 * @param submenu the menu to be added to the popup menu;
 * will be destroyed as a consequence of this method call
 */
final public void addMenuItems(JMenu submenu) {
    if (submenu != null && submenu.getItemCount() > 0) {
        // as we move items from the submenu to the main menu
        // the submenu gets modified
        while (submenu.getItemCount() > 0) {
            JMenuItem item = submenu.getItem(0);
            if (item == null) {
                submenu.remove(0);
                addSeparator();
            } else {
                add(item);
            }
        }
    }
}
项目:brModelo    文件:Controler.java   
public void PopuleBarra(JMenu obj) {
    int i = 0;
    for (ConfigAcao ca : Lista) {
        if (ca.tipo == TipoConfigAcao.tpMenuBarra || ca.tipo == TipoConfigAcao.tpAny) {
            Acao ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
            ac.IDX = i++;
            JMenuItem mi = new JMenuItem(ac);
            //obj.add(mi);
            listaMenus.put(ca.command, mi);
            //ListaDeAcoes.add(ac);
        }
    }
    obj.setText(Editor.fromConfiguracao.getValor("Controler.interface.menu.menuDiagrama.texto"));
    char b = Editor.fromConfiguracao.getValor("Controler.interface.menu.menuDiagrama.mtecla").charAt(0);
    obj.setMnemonic(b);
    BarraMenu = obj;
}
项目:trashjam2017    文件:Hiero.java   
private void initializeMenus () {
    {
        JMenuBar menuBar = new JMenuBar();
        setJMenuBar(menuBar);
        {
            JMenu fileMenu = new JMenu();
            menuBar.add(fileMenu);
            fileMenu.setText("File");
            fileMenu.setMnemonic(KeyEvent.VK_F);
            {
                openMenuItem = new JMenuItem("Open Hiero settings file...");
                openMenuItem.setMnemonic(KeyEvent.VK_O);
                openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
                fileMenu.add(openMenuItem);
            }
            {
                saveMenuItem = new JMenuItem("Save Hiero settings file...");
                saveMenuItem.setMnemonic(KeyEvent.VK_S);
                saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
                fileMenu.add(saveMenuItem);
            }
            fileMenu.addSeparator();
            {
                saveBMFontMenuItem = new JMenuItem("Save BMFont files (text)...");
                saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
                saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
                fileMenu.add(saveBMFontMenuItem);
            }
            fileMenu.addSeparator();
            {
                exitMenuItem = new JMenuItem("Exit");
                exitMenuItem.setMnemonic(KeyEvent.VK_X);
                fileMenu.add(exitMenuItem);
            }
        }
    }
}
项目:openjdk-jdk10    文件:AppleMenuDriver.java   
private static MenuElement getSelectedElement(MenuElement bar) {
    MenuElement[] subElements = bar.getSubElements();
    for (MenuElement subElement : subElements) {
        if (subElement instanceof JMenu
                && ((JMenu) subElement).isSelected()) {
            return subElement;
        } else if (subElement instanceof JMenuItem
                && ((JMenuItem) subElement).isSelected()) {
            return subElement;
        }
    }
    return null;
}
项目:AgentWorkbench    文件:MainWindow.java   
/**
 * This method can be used in order to add an individual menu at a specified index position of the menu bar.
 *
 * @param myMenu the my menu
 * @param indexPosition the index position
 */
public void addJMenu(JMenu myMenu, int indexPosition) {
    int nElements = jMenuBarMain.getSubElements().length;
    if (indexPosition > (nElements - 1)) {
        this.addJMenu(myMenu);
    } else {
        jMenuBarMain.add(myMenu, indexPosition);
        this.validate();
    }
}
项目:freecol    文件:InGameMenuBar.java   
private void buildViewMenu() {
    // --> View
    JMenu menu = Utility.localizedMenu("menuBar.view");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_V);

    menu.add(getCheckBoxMenuItem(MapControlsAction.id));
    menu.add(getCheckBoxMenuItem(DisplayGridAction.id));
    menu.add(getCheckBoxMenuItem(DisplayBordersAction.id));
    menu.add(getMenuItem(ToggleViewModeAction.id));
    menu.add(getCheckBoxMenuItem(ChangeWindowedModeAction.id));

    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();
    for (DisplayText type : DisplayText.values()) {
        menu.add(getRadioButtonMenuItem(DisplayTileTextAction.id
                + type.getKey(), group));
    }

    menu.addSeparator();
    menu.add(getMenuItem(ZoomInAction.id));
    menu.add(getMenuItem(ZoomOutAction.id));
    menu.add(getMenuItem(CenterAction.id));
    menu.add(getMenuItem(TilePopupAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(EuropeAction.id));
    menu.add(getMenuItem(TradeRouteAction.id));
    menu.add(getMenuItem(FindSettlementAction.id));

    add(menu);
}
项目:openjdk-jdk10    文件:JMenuBarOperator.java   
/**
 * Maps {@code JMenuBar.setHelpMenu(JMenu)} through queue
 */
public void setHelpMenu(final JMenu jMenu) {
    runMapping(new MapVoidAction("setHelpMenu") {
        @Override
        public void map() {
            ((JMenuBar) getSource()).setHelpMenu(jMenu);
        }
    });
}
项目:incubator-netbeans    文件:ProfilerPlugins.java   
List<JMenuItem> menuItems() {
    List<JMenuItem> menus = new ArrayList();

    if (plugins != null) for (ProfilerPlugin plugin : plugins) {
        try {
            JMenu menu = new JMenu(plugin.getName());
            plugin.createMenu(menu);
            if (menu.getItemCount() > 0) menus.add(menu);
        } catch (Throwable t) {
            handleThrowable(plugin, t);
        }
    }

    return menus;
}
项目:geomapapp    文件:AccessAllData.java   
public void traverseTree(DefaultMutableTreeNode root, JMenu rootMenu) {
    for (Enumeration e = root.children(); e.hasMoreElements(); ) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
        if ( child.isLeaf() ) {
            JMenuItem childMI = new JMenuItem(child.toString());
            rootMenu.add(childMI);
            childMI.addActionListener(this);
        } else {
            JMenu nextRootMenu = new JMenu(child.toString());
            traverseTree(child, nextRootMenu);
            rootMenu.add(nextRootMenu);
        }
    }
}
项目:openjdk-jdk10    文件:JMenuOperator.java   
/**
 * Maps {@code JMenu.insertSeparator(int)} through queue
 */
public void insertSeparator(final int i) {
    runMapping(new MapVoidAction("insertSeparator") {
        @Override
        public void map() {
            ((JMenu) getSource()).insertSeparator(i);
        }
    });
}
项目:mithril    文件:MithrilMenuBar.java   
public void init() {
    JMenu xpTrackersMenu = new JMenu("XP Trackers");

    for (int skill = 0; skill < Skills.NUM_SKILLS; skill++) {
        xpTrackersMenu.add(new XPTrackerMenuItem(skill));
    }

    add(xpTrackersMenu);
}
项目:javaportfolio    文件:MenuCreator.java   
public JMenu createViewMenu() {
    JMenu viewMenu = new JMenu("Näkymä");
    JMenuItem item;
    viewMenu.add(item = new JCheckBoxMenuItem(MENU_ITEM_SHOW_PARTIAL));
    item.addActionListener(this);

    return viewMenu;
}
项目:incubator-netbeans    文件:DragOperation.java   
JComponent getDeepestComponent(Point pt) {
    if(pt == null) return null;
    RADComponent rad = menuEditLayer.formDesigner.getHandleLayer().getMetaComponentAt(pt, HandleLayer.COMP_DEEPEST);
    if(rad != null && (JMenu.class.isAssignableFrom(rad.getBeanClass()) ||
            JMenuBar.class.isAssignableFrom(rad.getBeanClass()))) {
       return (JComponent) menuEditLayer.formDesigner.getComponent(rad);
    } else {
        return getDeepestComponentInPopups(pt);
    }
}
项目:incubator-netbeans    文件:AbstractMenuFactory.java   
public void componentAdded(ContainerEvent e) {
    JMenu menu = (JMenu) e.getContainer();
    JComponent item = (JComponent) e.getChild();
    //Mark the child as belonging to the parent container context
    String containerContext = getContainerContext(menu);

    item.putClientProperty (KEY_CONTAINERCONTEXT, containerContext);
}
项目:ramus    文件:MnemonicFactory.java   
private static void setMnemonics(final JMenuItem item) {
    if (item instanceof JMenu) {
        final JMenu menu = (JMenu) item;
        final int c = menu.getMenuComponentCount();
        final ArrayList<JMenuItem> list = new ArrayList<JMenuItem>(c);
        for (int i = 0; i < c; i++) {
            final Component co = menu.getMenuComponent(i);
            if (co instanceof JMenuItem)
                list.add((JMenuItem) co);

        }
        if (list.size() > 0)
            setMnemonics(list);
    }
}
项目:Tarski    文件:SimpleGUI.java   
/** This method refreshes the "file" menu. */
private Runner doRefreshFile() {
    if (wrap) return wrapMe();
    try {
        wrap = true;
        filemenu.removeAll();
        menuItem(filemenu, "New",     'N', 'N', doNew());
        menuItem(filemenu, "Open...", 'O', 'O', doOpen());
        if (!Util.onMac())
           menuItem(filemenu, "Open Sample Models...", VK_ALT, 'O', doBuiltin());
        else
           menuItem(filemenu, "Open Sample Models...", doBuiltin());
        JMenu recentmenu;
        filemenu.add(recentmenu = new JMenu("Open Recent"));
        menuItem(filemenu, "Reload all", 'R', 'R', doReloadAll());
        menuItem(filemenu, "Save",       'S', 'S', doSave());
        if (Util.onMac())
           menuItem(filemenu, "Save As...", VK_SHIFT, 'S', doSaveAs());
        else
           menuItem(filemenu, "Save As...", 'A', doSaveAs());
        menuItem(filemenu, "Close",                     'W', 'W',                         doClose());
        menuItem(filemenu, "Clear Temporary Directory",                                   doClearTemp());
        menuItem(filemenu, "Quit",                      'Q', (Util.onMac() ? -1 : 'Q'), doQuit());
        boolean found = false;
        for(Util.StringPref p: new Util.StringPref[]{ Model0, Model1, Model2, Model3 }) {
            String name = p.get();
            if (name.length()>0) { found = true; menuItem(recentmenu, name, doOpenFile(name)); }
        }
        recentmenu.addSeparator();
        menuItem(recentmenu, "Clear Menu", doClearRecent());
        recentmenu.setEnabled(found);
    } finally {
        wrap = false;
    }
    return null;
}
项目:routerapp    文件:Menu.java   
/**
 * Adds a menu item to this menu bar, under the given parent menu. The only action
 * that will be set to this item is showing a message that the chosen functionality
 * has not been implemented; this method should be used to add to a program menu
 * items of future implementations.
 * @param name the name of the new menu item
 * @param parentName the name of the parent menu in which to add the new item
 * @param tooltip the tooltip text that will be shown when the mouse is over this item
 * @param enabled indicates whether or not the item will be enabled
 */
public void addMenuItem (String name, String parentName, String tooltip,
        boolean enabled) {
     JMenu parentMenu = (JMenu) parentMenus.get(parentName);

     if (parentMenu != null) {
         JMenuItem newItem = new JMenuItem(name);
         newItem.setToolTipText(tooltip);
         EventHandler.getInstance().add(name,newItem);

         parentMenu.add(newItem);
     }
}
项目:incubator-netbeans    文件:MenuEditLayer.java   
public void hideMenuLayer() {
    // tear down each menu and menu item
    unconfigureFormListeners();
    unconfigureSelectionListener();
    for(JMenu m : menuPopupUIMap.keySet()) {
        unconfigureMenu(m);
    }
    menuPopupUIMap.clear();
    if(hackedPopupFactory != null) {
        hackedPopupFactory.containerMap.clear();
        hackedPopupFactory = null;
    }
    if(dragop.isStarted()) {
        dragop.fastEnd();
    }
    // close all popup frames
    this.setVisible(false);
    if(keyboardMenuNavigator != null) {
        glassLayer.removeKeyListener(keyboardMenuNavigator);
        keyboardMenuNavigator.unconfigure();
        keyboardMenuNavigator = null;
    }
    backgroundMap.clear();
    //hackedPopupFactory.containerMap.clear();
    if(formDesigner.getHandleLayer() != null) {
        formDesigner.getHandleLayer().requestFocusInWindow();
    }
}
项目:DeutschSim    文件:GUI.java   
public void setup() {           
    JSplitPane main_split_pane = create_main_split_pane();

    JSplitPane child_split_pane = setup_main_split_pane_top(main_split_pane);
    setup_main_split_pane_bottom(main_split_pane);

    setup_child_split_pane_left(child_split_pane);
    setup_child_split_pane_right(child_split_pane);

    JMenuBar menu_bar = create_menu_bar();

    JMenu file_menu = create_menu("File", menu_bar);
    add_item_new(file_menu);
    add_item_open(file_menu);
    add_item_save(file_menu);
    add_item_save_as(file_menu);
    file_menu.addSeparator();
    add_item_load_gate(file_menu);
    file_menu.addSeparator();
    add_item_quit(file_menu);

    JMenu circuit_menu = create_menu("Circuit", menu_bar);
    add_item_simulate(circuit_menu);
    add_item_change_qubits(circuit_menu);       
    circuit_menu.addSeparator();
    add_item_create_custom_gate(circuit_menu);

    JMenu help_menu = create_menu("Help", menu_bar);
    add_item_about(help_menu);
}
项目:openjdk-jdk10    文件:MisplacedBorder.java   
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
项目:incubator-netbeans    文件:MenuEditLayer.java   
void configureMenuItem(final JMenu parent, final JComponent c) {
    if(c instanceof JMenuItem) {
        JMenuItem item = (JMenuItem) c;
        if(!(item.getIcon() instanceof WrapperIcon)) {
            item.setIcon(new WrapperIcon(item.getIcon()));
        }
        installAcceleratorPreview(item);
        item.setBorderPainted(true);
    }
}
项目:openjdk-jdk10    文件:JMenuOperator.java   
/**
 * Maps {@code JMenu.removeMenuListener(MenuListener)} through queue
 */
public void removeMenuListener(final MenuListener menuListener) {
    runMapping(new MapVoidAction("removeMenuListener") {
        @Override
        public void map() {
            ((JMenu) getSource()).removeMenuListener(menuListener);
        }
    });
}
项目:jaer    文件:AEViewer.java   
/**
 * Finds the top-level menu named s.
 *
 * @param s the text of the menu. If null, returns null.
 * @return the menu, if there is one, or null if not found.
 */
public JMenu getMenu(String s) {
    if (s == null) {
        return null;
    }
    JMenuBar b = getJMenuBar();
    int n = b.getMenuCount();
    for (int i = 0; i < n; i++) {
        JMenu m = b.getMenu(i);
        if (m.getText().equals(s)) {
            return m;
        }
    }
    return null;
}
项目:incubator-netbeans    文件:MenuEditLayer.java   
private void makeSureShowingOnScreen(RADComponent rad, JComponent comp) {
    if(!this.isVisible()) {
        this.setVisible(true);
        registerKeyListeners();
        if(rad instanceof RADVisualContainer) {
            keyboardMenuNavigator.setCurrentMenuRAD((RADVisualContainer)rad);
        } else {
            keyboardMenuNavigator.setCurrentMenuRAD((RADVisualContainer)rad.getParentComponent());
        }
    }

    List<RADComponent> path = new ArrayList<RADComponent>();
    RADComponent temp = rad.getParentComponent();
    while(true) {
        if(temp == null) break;
        path.add(temp);
        temp = temp.getParentComponent();
        if(!isMenuRelatedRADComponent(temp)) {
            break;
        }
    }

    // go backwards, top to bottom
    for(int i = path.size()-1; i>=0; i--) {
        RADComponent r = path.get(i);
        JComponent c = (JComponent) formDesigner.getComponent(r);
        if(c instanceof JMenu) {
            showMenuPopup((JMenu)c);
        }
    }

}