Java 类javax.swing.JMenuItem 实例源码

项目:openjdk-jdk10    文件:JPopupMenuEndlessLoopTest.java   
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(() -> {

        JPopupMenu popup = new JPopupMenu("Popup Menu");
        JMenu menu = new JMenu("Menu");
        menu.add(new JMenuItem("Menu Item"));
        popup.add(menu);
        menu.doClick();
        MenuElement[] elems = MenuSelectionManager
                .defaultManager().getSelectedPath();

        if (elems == null || elems.length == 0) {
            throw new RuntimeException("Empty Selection");
        }

        if (elems[0] != popup || elems[1] != menu) {
            throw new RuntimeException("Necessary menus are not selected!");
        }
    });
}
项目:geomapapp    文件:MapLocations.java   
void initMenu() {
    addLoc = new JMenuItem("Add Place");
    menu.add( addLoc );
    addLoc.addActionListener( this );
    loadLoc = new JMenuItem("Load Places");
    menu.add( loadLoc );
    loadLoc.addActionListener( this );
    editLoc = new JMenuItem("Edit Places");
    menu.add( editLoc );
    editLoc.addActionListener( this );
    editLoc.setEnabled(false);
    showLoc = new JCheckBoxMenuItem("Show Places", false);
    menu.add( showLoc );
    showLoc.addActionListener( this );
//  showLoc.setEnabled(false);
    menu.addSeparator();
    list = new JCheckBox("add to list", true);
    save = new JCheckBox("save to file", false);
    newSave = new JCheckBox("save to new file", false);
    addPresetLocations();
//  addMyLocations();
}
项目:javaportfolio    文件:PortfolioGuiApp.java   
/**
 * Handle menu command.
 * 
 * @param item
 *            the item
 */
public void handleMenuCommand(JMenuItem item) {
    if (item.getText().equals(MenuCreator.MENU_ITEM_NEW_PORTFOLIO)) {
        handleNewPortfolio();
    } else if (item.getText().equals(MenuCreator.MENU_ITEM_OPEN_PORTFOLIO)) {
        handleOpenPortfolio();
    } else if (item.getText()
            .equals(MenuCreator.MENU_ITEM_IMPORT_PORTFOLIO)) {
        handleImportPortfolio();
    } else if (item.getText().equals(MenuCreator.MENU_ITEM_QUIT)) {
        System.exit(0);
    } else if (item.getText().equals(MenuCreator.MENU_ITEM_UPDATE_OMX_HEX)) {
        updateQuotes();
    } else if (item.getText().equals(MenuCreator.MENU_ITEM_ABOUT)) {
        handleAbout();
    } else {
        if (portfolioDocument != null) {
            portfolioDocument.handleMenuCommand(item);
        }
    }
}
项目:incubator-netbeans    文件:SchedulingPickerImpl.java   
private void showSchedulingPopup () {
    final DashboardUtils.SchedulingMenu menu = new DashboardUtils.SchedulingMenu(currentValue);
    menu.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged (ChangeEvent e) {
            updateCurrentValue(menu.getScheduleInfo());
            menu.removeChangeListener(this);
        }
    });
    JPopupMenu popup = new JPopupMenu();
    for (JMenuItem item : menu.getMenuItems()) {
        if (item == null) {
            popup.addSeparator();
        } else {
            popup.add(item);
        }
    }
    Point p = scheduleTextComponent.getLocation();
    popup.show(scheduleTextComponent.getParent(), p.x, p.y + scheduleTextComponent.getSize().height + 1);
}
项目:incubator-netbeans    文件:BindAction.java   
private void createBindingsSubmenu(JMenu menu) {
    if (menu.getMenuComponentCount() > 0)
        menu.removeAll();

    Node[] nodes = getActivatedNodes();
    if (nodes.length != 1)
        return;

    RADComponentCookie radCookie = nodes[0].getCookie(RADComponentCookie.class);
    if (radCookie == null)
        return;

    BindingProperty[][] bindingProps = radCookie.getRADComponent().getBindingProperties();
    BindingProperty[] props = bindingProps[(bindingProps[0].length==0) ? 1 : 0];
    if (props.length > 0) {
        for (BindingProperty prop : props) {
            BindingMenuItem mi = new BindingMenuItem(prop);
            mi.addActionListener(mi);
            menu.add(mi);
        }
    } else {
        JMenuItem item = new JMenuItem(NbBundle.getMessage(BindAction.class, "MSG_NoBinding")); // NOI18N
        item.setEnabled(false);
        menu.add(item);
    }
}
项目:DeutschSim    文件:GUI.java   
private void add_item_new(final JMenu file_menu) {
    JMenuItem item_new = new JMenuItem(new AbstractAction("New") {
        private static final long serialVersionUID = 3699016056959009199L;

        @Override
        public void actionPerformed(ActionEvent arg0) {
            frame.getContentPane().removeAll();
            setup();
            // TODO add restoration of JSplitPanes' panels' sizes
            frame.validate();
            set_current_file(null);
        }
    });
    item_new.setAccelerator(KeyStroke.getKeyStroke('N', menu_mask));
    file_menu.add(item_new);
}
项目:incubator-netbeans    文件:DropTargetLayer.java   
private static int getIconLeft(JMenuItem item) {
    if(Utilities.isWindows()) {
        if(isVista()) {
            return 1;
        }
        if(hasRadioOrCheckSibling(item)) {
            return 20;
        } else {
            return 20;
        }
    }

    if(isAqua()) {
        if(item instanceof JRadioButtonMenuItem) {
            return 11;
        }
        return 14;
    }

    //metal or other (hopefully) basic derived L&Fs
    if(isRadioOrCheck(item)) {
        return 20;
    }
    return 10;
}
项目:incubator-netbeans    文件:InfoPanel.java   
private JButton createArrowButton() {
    arrowMenu = new JPopupMenu();
    JButton button = DropDownButtonFactory.createDropDownButton(
        ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/debuggingView/unvisited_bpkt_arrow_small_16.png", false), arrowMenu);
    button.setPreferredSize(new Dimension(40, button.getPreferredSize().height)); // [TODO]
    button.setMaximumSize(new Dimension(40, button.getPreferredSize().height)); // [TODO]
    button.setFocusable(false);
    button.setOpaque(false);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (arrowMenu.getComponentCount() > 0) {
                Object item = arrowMenu.getComponent(0);
                for (Map.Entry<DVThread, JMenuItem> entry : threadToMenuItem.entrySet()) {
                    if (entry.getValue() == item) {
                        debuggingView.makeThreadCurrent(entry.getKey());
                    } // if
                } // for
            } // if
        } // actionPerformed
    });
    return button;
}
项目:Luyten4Forge    文件:FileSaver.java   
public FileSaver(JProgressBar bar, JLabel label) {
    this.bar = bar;
    this.label = label;
    final JPopupMenu menu = new JPopupMenu("Cancel");
    final JMenuItem item = new JMenuItem("Cancel");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            setCancel(true);
        }
    });
    menu.add(item);
    this.label.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent ev) {
            if (SwingUtilities.isRightMouseButton(ev) && isExtracting())
                menu.show(ev.getComponent(), ev.getX(), ev.getY());
        }
    });
}
项目:s-store    文件:DatabaseManagerSwing.java   
private void addToRecent(String s) {

        for (int i = 0; i < iMaxRecent; i++) {
            if (s.equals(sRecent[i])) {
                return;
            }
        }

        if (sRecent[iRecent] != null) {
            mRecent.remove(iRecent);
        }

        sRecent[iRecent] = s;

        if (s.length() > 43) {
            s = s.substring(0, 40) + "...";
        }

        JMenuItem item = new JMenuItem(s);

        item.setActionCommand("#" + iRecent);
        item.addActionListener(this);
        mRecent.insert(item, iRecent);

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:incubator-netbeans    文件:Actions.java   
/** @param changedProperty the name of property that has changed
* or null if it is not known
*/
@Override
public void updateState(String changedProperty) {
    super.updateState(changedProperty);

    if ((changedProperty == null) || !changedProperty.equals(Action.ACCELERATOR_KEY)) {
        updateKey((JMenuItem) comp, action);
    }

    if ((changedProperty == null) || changedProperty.equals(Action.NAME)) {
        Object s = action.getValue(Action.NAME);

        if (s instanceof String) {
            setMenuText(((JMenuItem) comp), (String) s, true);
        }
    }
}
项目:incubator-netbeans    文件:ActionFactory.java   
public JMenuItem getPopupMenuItem(JTextComponent target) {

    item = new JCheckBoxMenuItem(NbBundle.getBundle(BaseKit.class).
            getString("line-numbers-menuitem"), isLineNumbersVisible());
    item.addItemListener( new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    return item;
}
项目:rapidminer    文件:DockableResultDisplay.java   
public DockableResultDisplay() {
    this.dockKey.setDockGroup(MainFrame.DOCK_GROUP_RESULTS);
    DockableActionCustomizer customizer = new DockableActionCustomizer() {

        @Override
        public void visitTabSelectorPopUp(JPopupMenu popUpMenu, Dockable dockable) {
            popUpMenu.add(new JMenuItem(new CloseAllResultsAction(RapidMinerGUI.getMainFrame())));
        }
    };
    customizer.setTabSelectorPopUpCustomizer(true); // enable tabbed dock custom popup menu
                                                     // entries
    this.dockKey.setActionCustomizer(customizer);
    setLayout(new BorderLayout());
    ExtendedJScrollPane overviewScrollpane = new ExtendedJScrollPane(overview);
    overviewScrollpane.setBorder(null);
    overviewScrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    overviewScrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    add(overviewScrollpane, BorderLayout.CENTER);
    tableUpdateQueue.start();
}
项目:incubator-netbeans    文件:MenuChecker.java   
/** Open all menus in menubar
 * @param menu  to be visited */
public static void visitMenuBar(JMenuBar menu) {
    MenuElement[] elements = menu.getSubElements();

    JMenuBarOperator op = new JMenuBarOperator(menu);

    for (int k = 0; k < elements.length; k++) {
        if (elements[k] instanceof JMenuItem) {
            op.pushMenu(((JMenuItem) elements[k]).getText(), "/", true, true);
            try {
                op.wait(200);
            } catch (Exception e) {
            }
        }
    }
}
项目:FreeCol    文件:QuickActionMenu.java   
/**
 * Add an item to pay arrears on the given goods type.
 *
 * @param goodsType The {@code GoodsType} to pay arrears on.
 */
private void addPayArrears(final GoodsType goodsType) {
    final InGameController igc = freeColClient.getInGameController();

    JMenuItem menuItem = Utility.localizedMenuItem("payArrears");
    menuItem.addActionListener((ActionEvent ae) -> {
            igc.payArrears(goodsType);
            // FIXME: fix pcls so this hackery can go away
            if (parentPanel instanceof CargoPanel) {
                CargoPanel cargoPanel = (CargoPanel) parentPanel;
                cargoPanel.initialize();
            }
            parentPanel.revalidate();
        });
    this.add(menuItem);
}
项目: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;
}
项目:marathonv5    文件:JMenuItemJavaElementTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    JavaElementFactory.add(JMenuItem.class, JMenuItemJavaElement.class);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JMenuItemJavaElementTest.class.getSimpleName());
            frame.setName("frame-" + JMenuItemJavaElementTest.class.getSimpleName());
            MenuDemo demo = new MenuDemo();
            frame.setJMenuBar(demo.createMenuBar());
            frame.setContentPane(demo.createContentPane());
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    MenuSelectionManager.defaultManager().clearSelectedPath();
    driver = new JavaAgent();
    menus = driver.findElementsByTagName("menu");
    AMenu = menus.get(0);

}
项目:openjdk-jdk10    文件:CloseOnMouseClickPropertyTest.java   
private static void createAndShowGUI(TestItem testItem) {

        frame = new JFrame();
        frame.setSize(300, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JMenuBar menuBar = new JMenuBar();
        menu = new JMenu("Menu");
        JMenuItem menuItem = testItem.getMenuItem();
        testItem.setProperties(menuItem);
        menu.add(menuItem);
        menuBar.add(menu);

        frame.setJMenuBar(menuBar);
        frame.setVisible(true);
    }
项目:OpenJSharp    文件:XTextFieldEditor.java   
@Override
public void  actionPerformed(ActionEvent e) {
    super.actionPerformed(e);
    if ((e.getSource() instanceof JMenuItem) ||
        (e.getSource() instanceof JTextField)) {
        fireEditingStopped();
    }
}
项目:incubator-netbeans    文件:IgnoreMenu.java   
@Override
public JMenuItem getPopupPresenter() {
    JMenu menu = createMenu();
    menu.setText(Bundle.CTL_MenuItem_IgnoreMenu_popupName());
    enableMenu(menu);
    return menu;
}
项目:poi-visualizer    文件:POIContextMenu.java   
@PostConstruct
public void init() {
    if (isInit) {
        return;
    }

    isInit = true;

    saveStream = new JMenuItem("Save ...", KeyEvent.VK_S);
    saveStream.addActionListener(e -> saveFile());

    add(saveStream);
}
项目:rapidminer    文件:ClipboardActionsPopup.java   
public ClipboardActionsPopup(JTextComponent parent) {
    this.parent = parent;

    this.cutMenuItem = new JMenuItem(new ResourceActionTransmitter("editor.cut",
            new javax.swing.text.DefaultEditorKit.CutAction()));
    this.copyMenuItem = new JMenuItem(new ResourceActionTransmitter("editor.copy",
            new javax.swing.text.DefaultEditorKit.CopyAction()));
    this.pasteMenuItem = new JMenuItem(new ResourceActionTransmitter("editor.paste",
            new javax.swing.text.DefaultEditorKit.PasteAction()));
    this.deleteMenuItem = new JMenuItem(new ResourceActionTransmitter("editor.delete",
            new TextActions.DeleteTextAction()));

    // this.clearMenuItem = new JMenuItem(new TextActions.ClearAction());

    this.selectAllMenuItem = new JMenuItem(new ResourceActionTransmitter("editor.select_all",
            new TextActions.SelectAllAction()));

    this.add(this.cutMenuItem);
    this.add(this.copyMenuItem);
    this.add(this.pasteMenuItem);
    this.add(this.deleteMenuItem);
    this.addSeparator();
    // this.add(this.clearMenuItem);
    this.add(this.selectAllMenuItem);

    // this.setPreferredSize(new Dimension((int) this.getPreferredSize().getWidth() + 30, (int)
    // this.getPreferredSize().getHeight()));
}
项目:incubator-netbeans    文件:DynamicMenu.java   
@Override
public JMenuItem getMenuPresenter() {
    JMenu menu = createMenu();
    org.openide.awt.Mnemonics.setLocalizedText(menu, menu.getText());
    enableMenu(menu);
    return menu;
}
项目:scorekeeperfrontend    文件:ProSoloInterface.java   
protected JMenuItem createMenu(String title, int key, int modifier)
{
    JMenuItem item = new JMenuItem(title);
    if (key != 0) item.setAccelerator(KeyStroke.getKeyStroke(key, modifier));
    item.addActionListener(this);
    return item;
}
项目:parabuild-ci    文件:DatabaseManagerSwing.java   
private void addMenuItems(JMenu f, String m[]) {

        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

        for (int i = 0; i < m.length; i++) {
            if (m[i].equals("--")) {
                f.addSeparator();
            } else if (m[i].equals("---")) {

                // (ulrivo): full size on screen with less than 640 width
                if (d.width >= 640) {
                    f.addSeparator();
                } else {
                    return;
                }
            } else {
                JMenuItem item = new JMenuItem(m[i].substring(1));
                char      c    = m[i].charAt(0);

                if (c != '-') {
                    KeyStroke key =
                        KeyStroke.getKeyStroke(c, Event.CTRL_MASK);

                    item.setAccelerator(key);
                }

                item.addActionListener(this);
                f.add(item);
            }
        }
    }
项目:Random-Music-Generator    文件:GeneratorMenu.java   
public GeneratorMenu(Window window, ControllPanel genPanel, ArrayList<IMusicGenerator> musicGens,
        ArrayList<ISongChangeObserver> songChangeObservers){
    super("Generator");
    components = new ArrayList<JMenuItem>();
    this.window = window;
    this.genPanel = genPanel;
    this.musicGenList = musicGens;
    songChangeObserverList = songChangeObservers;
    for(IMusicGenerator musicGen: musicGenList){
        JMenuItem menuItem = new JMenuItem(musicGen.getGeneratorName());
        menuItem.addActionListener(new ActionHandler(musicGen));
        components.add(menuItem);
        add(menuItem);
    }
}
项目:routerapp    文件:MenuManagementWindow.java   
/**
 * Builds a list from the components array.
 * @param components the components array
 * @return a list to be placed on the GUI
 */
JList buildListFromComponents (Component [] components) {
    JList list = new JList();

    if (components != null) {
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.setSize(100,200);

        listData = new Vector();
        menuItems = new Hashtable();

        // build a hash look-up table and fill list with components's text
        for (int i=0 ; i<components.length ; i++) {
            if (components[i] instanceof JMenuItem) {
                listData.addElement(((JMenuItem)components[i]).getText());
                menuItems.put(((JMenuItem)components[i]).getText(),components[i]);
            }
            else {
                listData.addElement(SEPARATOR_STRING);
                menuItems.put(SEPARATOR_STRING,components[i]);
            }
        }

        list.setListData(listData);
    }

    return list;
}
项目:jmt    文件:WhatIfPlot.java   
public PlotPopupMenu() {
    restore = new JMenuItem("Original view");
    zoomIn = new JMenuItem("Zoom in");
    zoomOut = new JMenuItem("Zoom out");
    saveAs = new JMenuItem("Save as...");
    saveAsWithLegend = new JMenuItem("Save as with legend...");
    this.add(restore);
    this.add(zoomIn);
    this.add(zoomOut);
    this.addSeparator();
    this.add(saveAs);
    this.add(saveAsWithLegend);
    addListeners();
}
项目:incubator-netbeans    文件:MoreAction.java   
/**
 * Remove DELETE accelerator from Delete action, because it is used by Hide
 * action in this context.
 */
private void removeDeleteAccelerator(Component item) {
    if (item instanceof JMenuItem) {
        JMenuItem mItem = (JMenuItem) item;
        if (DELETE_KS.equals(mItem.getAccelerator())) {
            mItem.setAccelerator(null);
        }
    }
}
项目:jaer    文件:DavisBaseCamera.java   
@Override
public void onRegistration() {
    super.onRegistration();
    if (getAeViewer() == null) {
        return;
    }
    helpMenuItem1 = getAeViewer().addHelpURLItem(DavisBaseCamera.HELP_URL_HW_USERGUIDES, "inilabs hardware user guides overview", "Opens product overview guide");
    helpMenuItem2 = getAeViewer().addHelpURLItem(DavisBaseCamera.USER_GUIDE_URL_DAVIS240, "DAVIS240 user guide",
            "Opens DAVIS240 user guide");
    helpMenuItem3 = getAeViewer().addHelpURLItem(DavisBaseCamera.USER_GUIDE_URL_FLASHY, "Flashy user guide",
            "User guide for external tool flashy for firmware/logic updates to devices using the libusb driver");

    davisMenu = new JMenu("DAVIS");
    davisMenu.add(new JMenuItem(new ToggleEventsAction()));
    davisMenu.add(new JMenuItem(new ToggleFrameCaptureDisplayAction()));
    davisMenu.add(new JSeparator());
    davisMenu.add(new JMenuItem(new ToggleAutoContrast()));
    davisMenu.add(new JMenuItem(new ToggleHistogram()));
    davisMenu.add(new JSeparator());
    davisMenu.add(new JMenuItem(new ToggleGlobalRollingShutter()));
    davisMenu.add(new JSeparator());
    davisMenu.add(new JMenuItem(new ToggleAutoExposure()));
    davisMenu.add(new JMenuItem(new IncreaseAPSExposure()));
    davisMenu.add(new JMenuItem(new DecreaseExposureAction()));
    davisMenu.add(new JSeparator());
    davisMenu.add(new JMenuItem(new IncreaseFrameRateAction()));
    davisMenu.add(new JMenuItem(new DecreaseFrameRateAction()));
    davisMenu.add(new JSeparator());
    davisMenu.add(new JMenuItem(new ToggleIMU()));
    davisMenu.getPopupMenu().setLightWeightPopupEnabled(false);
    getAeViewer().addMenu(davisMenu);
}
项目:incubator-netbeans    文件:CollectSystemAction.java   
private JMenuItem[] createMenu (Collection coll) {
    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (
        "\n--> CollectSystemAction.createMenu: ( " + coll + " )");

    ArrayList items = new ArrayList ();

    Iterator it = coll.iterator();
    while (it.hasNext ()) {
        SystemAction a = (SystemAction) it.next();

        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (
            "-*- CollectSystemAction.createMenu: next action " + a +
                         " -- " + ( a.isEnabled() ? "<enabled>" : "[disabled]" ) );

        if ( a.isEnabled() ) {
            JMenuItem item = null;
            if (a instanceof Presenter.Popup) {
                item = ((Presenter.Popup)a).getPopupPresenter ();
            }

            if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug
                ("-*- CollectSystemAction.createMenu: menu item = " + item);

            // test if we obtained the item
            if (item != null) {
                items.add (item);
            }
        }
    }

    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug
        ("<-- CollectSystemAction.createMenu: all items = " + items + "\n");

    JMenuItem[] array = new JMenuItem [items.size ()];
    items.toArray (array);
    return array;
}
项目:sstore-soft    文件:AbstractMenuHandler.java   
@Override
public void itemStateChanged(ItemEvent e) {
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Item event detected.\n"
               + "    Event source: " + source.getText()
               + " (an instance of " + source.getClass().getName() + ")\n"
               + "    New state: "
               + ((e.getStateChange() == ItemEvent.SELECTED) ?
                 "selected":"unselected") + "\n\n";
    System.err.println(s);
 }
项目: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    文件:EditorsAction.java   
@Override
public JMenuItem getMenuPresenter() {
    JMenu menu = new UpdatingMenu();
    String label = NbBundle.getMessage(EditorsAction.class, "CTL_EditorsAction");
    Mnemonics.setLocalizedText(menu, label);
    return menu;
}
项目:incubator-netbeans    文件:QueuesMenu.java   
@Override
public JMenuItem getPopupPresenter() {
    JMenu menu = createMenu();
    menu.setText(Bundle.CTL_MenuItem_QueuesMenu_popupName());
    enableMenu(menu);
    return menu;
}
项目:incubator-netbeans    文件:AbstractContextMenuFactory.java   
private JMenuItem getOrCreateMenuItem(int type) {
    JMenuItem result = type == ActionProvider.ACTION_TYPE_ITEM ? new JMenuItem() :
        type == ActionProvider.ACTION_TYPE_SUBCONTEXT ? new JMenu() : null;
    if (type == ActionProvider.ACTION_TYPE_ITEM) {
        result.addActionListener (getItemListener());
    } else if (type == ActionProvider.ACTION_TYPE_SUBCONTEXT){
        //attachToMenu ((JMenu) result);
    }
    result.putClientProperty (KEY_CREATOR, this);
    return result;
}
项目:Java-RPG-Maker-MV-Decrypter    文件:GUI_Menu.java   
/**
 * Creates the Info-Menu
 */
private void constructInfoMenu() {
    this.info = new JMenu("Info");

    this.help = new JMenuItem("Help");
    this.reportABug = new JMenuItem("Report a Bug...");
    this.about = new JMenuItem("About");
}
项目:openjdk-jdk10    文件:JMenuItemOperator.java   
/**
 * Maps
 * {@code JMenuItem.processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)}
 * through queue
 */
public void processMouseEvent(final MouseEvent mouseEvent, final MenuElement[] menuElement, final MenuSelectionManager menuSelectionManager) {
    runMapping(new MapVoidAction("processMouseEvent") {
        @Override
        public void map() {
            ((JMenuItem) getSource()).processMouseEvent(mouseEvent, menuElement, menuSelectionManager);
        }
    });
}
项目:incubator-netbeans    文件:LookupSensitiveActionUILogTest.java   
public void testMenuPushIsNotified() throws Exception {
       TestSupport.ChangeableLookup lookup = new TestSupport.ChangeableLookup();
       TestLSA tlsa = new TestLSA( lookup );
assertTrue ("TestLSA action is enabled.", tlsa.isEnabled ());
tlsa.refreshCounter = 0;
       TestPropertyChangeListener tpcl = new TestPropertyChangeListener();
       tlsa.addPropertyChangeListener( tpcl );
       lookup.change(d2);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );
       assertTrue("Action is enabled", tlsa.isEnabled());

       tlsa.setDisplayName("Jarda");


       JMenuItem item = new JMenuItem(tlsa);
       item.doClick();

       assertEquals("One record logged:\n" + my.recs, 1, my.recs.size());
       LogRecord r = my.recs.get(0);
       assertEquals("Menu push", "UI_ACTION_BUTTON_PRESS", r.getMessage());
       assertEquals("four args", 5, r.getParameters().length);
       assertEquals("first is the menu item", item, r.getParameters()[0]);
       assertEquals("second is its class", JMenuItem.class.getName(), r.getParameters()[1]);
       assertEquals("3rd is action", tlsa, r.getParameters()[2]);
       assertEquals("4th its class", tlsa.getClass().getName(), r.getParameters()[3]);
       assertEquals("5th name", "Jarda", r.getParameters()[4]);

       tlsa.clear();
       tpcl.clear();
       lookup.change(d3);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );        
   }
项目:marathonv5    文件:RMenuItemTest.java   
private List<JMenuItem> getMenuComponents(JMenu AMenu) {
    Component[] components = AMenu.getMenuComponents();
    List<JMenuItem> items = new ArrayList<JMenuItem>();
    for (int j = 0; j < components.length; j++) {
        if (!(components[j] instanceof AbstractButton)) {
            continue;
        }
        items.add((JMenuItem) components[j]);
    }
    return items;
}