Java 类java.awt.MenuItem 实例源码

项目:litiengine    文件:Program.java   
private static Menu initProjectMenu() {
  Menu mnProject = new Menu(Resources.get("menu_project"));

  CheckboxMenuItem compress = new CheckboxMenuItem(Resources.get("menu_compressProjectFile"));
  compress.setState(userPreferences.isCompressFile());
  compress.addItemListener(e -> userPreferences.setCompressFile(compress.getState()));

  CheckboxMenuItem sync = new CheckboxMenuItem(Resources.get("menu_syncMaps"));
  sync.setState(userPreferences.isSyncMaps());
  sync.addItemListener(e -> userPreferences.setSyncMaps(sync.getState()));

  MenuItem importSpriteFile = new MenuItem(Resources.get("menu_assets_importSpriteFile"));
  importSpriteFile.addActionListener(a -> EditorScreen.instance().importSpriteFile());

  MenuItem importSprite = new MenuItem(Resources.get("menu_assets_importSprite"));
  importSprite.addActionListener(a -> EditorScreen.instance().importSprites());

  mnProject.add(importSprite);
  mnProject.add(importSpriteFile);
  mnProject.addSeparator();
  mnProject.add(compress);
  mnProject.add(sync);

  return mnProject;
}
项目:litiengine    文件:Program.java   
private static void initSystemTray() {
  // add system tray icon with popup menu
  if (SystemTray.isSupported()) {
    SystemTray tray = SystemTray.getSystemTray();
    PopupMenu menu = new PopupMenu();
    MenuItem exitItem = new MenuItem(Resources.get("menu_exit"));
    exitItem.addActionListener(a -> Game.terminate());
    menu.add(exitItem);

    trayIcon = new TrayIcon(RenderEngine.getImage("pixel-icon-utility.png"), Game.getInfo().toString(), menu);
    trayIcon.setImageAutoSize(true);
    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
  }
}
项目:EasyFXML    文件:SystemTraySupportTest.java   
@Test
public void register_system_tray_icon() throws ExecutionException, InterruptedException {
    final SystemTraySupport systemTraySupport = this.applicationContext.getBean(SystemTraySupport.class);

    final MenuItem testItem = new MenuItem("DISABLED_ON_CLICK");
    final ActionListener disableOnClick = e -> testItem.setEnabled(false);

    final Map<MenuItem, ActionListener> menuItems = new HashMap<MenuItem, ActionListener>() {{
        this.put(testItem, disableOnClick);
    }};

    final SystemTrayIcon trayIcon = this.systemTrayIconWith(menuItems);
    systemTraySupport.registerTrayIcon(trayIcon)
        .whenCompleteAsync((res, err) -> assertThat(res.isSuccess()).isTrue())
        .thenApply(Try::get)
        .whenCompleteAsync((res, err) -> assertThat(systemTraySupport.getTrayIcons()).containsExactly(res))
        .whenCompleteAsync((res, err) -> systemTraySupport.removeTrayIcon(res))
        .thenAccept(icon -> assertThat(systemTraySupport.getTrayIcons()).doesNotContain(icon))
        .toCompletableFuture().get();
}
项目:EasyFXML    文件:SystemTraySupportTest.java   
private SystemTrayIcon systemTrayIconWith(final Map<MenuItem, ActionListener> menuItems) {
    return new SystemTrayIcon() {
        @Override
        public String getLabel() {
            return TRAY_LABEL;
        }

        @Override
        public URL getIcon() {
            return TRAY_ICON_URL;
        }

        @Override
        public Map<MenuItem, ActionListener> getMenuItems() {
            return menuItems;
        }
    };
}
项目:OpenDiabetes    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:sstore-soft    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:s-store    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:dev-courses    文件:DatabaseManager.java   
void addMenuItems(Menu f, String[] m) {

        for (int i = 0; i < m.length; i++) {
            MenuItem item = new MenuItem(m[i].substring(1));
            char     c    = m[i].charAt(0);

            if (c != '-') {
                item.setShortcut(new MenuShortcut(c));
            }

            item.addActionListener(this);
            f.add(item);
        }
    }
项目:dev-courses    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:parabuild-ci    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:parabuild-ci    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:openjdk-jdk10    文件:UpdatePopupMenu.java   
private PopupMenu createPopupMenu(final TrayIcon trayIcon,
        final int menuCount) {

    final PopupMenu trayIconPopupMenu = new PopupMenu();

    for (int i = 1; i <= menuCount; ++i) {
        final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);

        popupMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
                trayIcon.setPopupMenu(createPopupMenu(trayIcon,
                        menuCount + 1));
            }
        });

        trayIconPopupMenu.add(popupMenuItem);
    }

    return trayIconPopupMenu;
}
项目:openjdk9    文件:UpdatePopupMenu.java   
private PopupMenu createPopupMenu(final TrayIcon trayIcon,
        final int menuCount) {

    final PopupMenu trayIconPopupMenu = new PopupMenu();

    for (int i = 1; i <= menuCount; ++i) {
        final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);

        popupMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
                trayIcon.setPopupMenu(createPopupMenu(trayIcon,
                        menuCount + 1));
            }
        });

        trayIconPopupMenu.add(popupMenuItem);
    }

    return trayIconPopupMenu;
}
项目:timetray    文件:TimeTray.java   
/**
 * creates a PopUp menu for the TrayIcon
 *
 * @return PopUp menu for the TrayIcon
 */
private PopupMenu createMenu() {
    PopupMenu menu = new PopupMenu("TimeTray " + this.VERSION);

    // about item
    MenuItem menuSettings = new MenuItem("Settings");
    menuSettings.setActionCommand("settings");
    menu.add(menuSettings);

    // exit item
    MenuItem menuExit = new MenuItem("Quit");
    menuExit.setActionCommand("quit");
    menu.add(menuExit);

    menu.addActionListener(this);

    return menu;
}
项目:Tingeltangel    文件:MasterFrameMenu.java   
private static MenuItem generateMenuItem(TreeElement element) {
    if(element.isLeaf()) {
        MenuItem item = new MenuItem(element.getCaption());
        item.addActionListener(new MasterFrameMenu(element.getFullID()));
        if(element.isHidden()) {
            item.setEnabled(false);
        } else if(!element.getEnabled()) {
            item.setEnabled(false);
        }
        items.put(element.getFullID(), item);
        return(item);
    } else {
        Menu menu = new Menu(element.getCaption());
        Iterator<TreeElement> i = element.getChilds();
        while(i.hasNext()) {
            menu.add(generateMenuItem(i.next()));
        }
        if(element.isHidden()) {
            menu.setEnabled(false);
        }
        items.put(element.getFullID(), menu);
        return(menu);
    }
}
项目:VoltDB    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:VoltDB    文件:Transfer.java   
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
private void addMenuItems(Menu f, String[] m) {

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

            item.addActionListener(this);
            f.add(item);
        }
    }
}
项目:deskshare-public    文件:SimpleUI.java   
private PopupMenu createPopupMenu() {
    final PopupMenu popup = new PopupMenu();
    if (allowScreenSwitch) {
        MenuItem switchItem = new MenuItem(Main.getString("text.switchscreen"));
        switchItem.setActionCommand("switch");
        switchItem.addActionListener(this);
        // add to popup
        popup.add(switchItem);
    }
    MenuItem exitItem = new MenuItem(Main.getString("text.exit"));
    exitItem.setActionCommand("exit");
    exitItem.addActionListener(this);
    // add to pop-up menu
    popup.add(exitItem);
    return popup;
}
项目:Processing-Arduino-Light-Controller    文件:SystemTrayHandler.java   
private void addExitItem( PopupMenu popup )
{
    MenuItem exit = new MenuItem( "Exit" );
    exit.addActionListener( new ActionListener()
    {
        @Override
        public void actionPerformed( ActionEvent e )
        {
            // Exits the program
            // plugin.resetLeds();
            // TODO: Decide whether or not LEDS should turn off when
            // program exits.
            //      Pros: You can set a color and then quit the program
            //      Cons: For LEDS to turn off, user has to unload plugins
            System.exit(0);
        }
    });
    popup.add( exit );
}
项目:Desktop    文件:JStickyNotes.java   
@Override
public void actionPerformed(ActionEvent e) {
    String label = ((MenuItem) e.getSource()).getLabel();
    if (CREATE_NOTE_TEXT.equals(label)) {
        createNote();
    } else if (SHOW_ALL_NOTES_TEXT.equals(label)) {
        showNotes(ALL);
    } else if (HIDE_ALL_NOTES_TEXT.equals(label)) {
        showNotes(NONE);
    } else if (PREFERENCES_TEXT.equals(label)) {
        new PreferencesDialog(frame, preferencesManager.getPreferences()).setVisible(true);
    } else if (ABOUT_TEXT.equals(label)) {
        JLabel about = new JLabel(ABOUT_DIALOG_TEXT);
        about.setIcon(Icon.getJStickyNotesImageIcon(48));
        JOptionPane.showMessageDialog(frame, about, ABOUT_DIALOG_TITLE_TEXT, JOptionPane.PLAIN_MESSAGE);
    } else if (EXIT_TEXT.equals(label)) {
        System.exit(0);
    }
}
项目:openblocks    文件:ContextMenu.java   
/**
 * Initializes the context menu for adding Comments.
 */
private static void initAddCommentMenu() {
    ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");

    addCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.add_comment"));
    addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
    addCommentItem.addActionListener(rndBlockMenu);
    addCommentMenu.add(addCommentItem);

    cloneItem1 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
    cloneItem1.setActionCommand(CLONE_BLOCK);
    cloneItem1.addActionListener(rndBlockMenu);
    addCommentMenu.add(cloneItem1);

    addCommentMenuInit = true;

}
项目:openblocks    文件:ContextMenu.java   
/**
 * Initializes the context menu for deleting Comments.
 */
private static void initRemoveCommentMenu() {
    ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");

    removeCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.delete_comment"));
    removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
    removeCommentItem.addActionListener(rndBlockMenu);

    removeCommentMenu.add(removeCommentItem);
    //rndBlockMenu.add(runBlockItem);


    cloneItem2 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
    cloneItem2.setActionCommand(CLONE_BLOCK);
    cloneItem2.addActionListener(rndBlockMenu);
    removeCommentMenu.add(cloneItem2);

    removeCommentMenuInit = true;
}
项目:oStorybook    文件:LangToolMain.java   
private PopupMenu makePopupMenu() {
    final PopupMenu popup = new PopupMenu();
    final ActionListener rmbListener = new TrayActionRMBListener();
    // Check clipboard text:
    final MenuItem checkClipboardItem = new MenuItem(
            StringTools.getLabel(messages
                    .getString("guiMenuCheckClipboard")));
    checkClipboardItem.addActionListener(rmbListener);
    popup.add(checkClipboardItem);
    // Open main window:
    final MenuItem restoreItem = new MenuItem(StringTools.getLabel(messages
            .getString("guiMenuShowMainWindow")));
    restoreItem.addActionListener(rmbListener);
    popup.add(restoreItem);
    // Exit:
    final MenuItem exitItem = new MenuItem(StringTools.getLabel(messages
            .getString("guiMenuQuit")));
    exitItem.addActionListener(rmbListener);
    popup.add(exitItem);
    return popup;
}
项目:Ardublock-for-Dwenguino    文件:ContextMenu.java   
/**
 * Initializes the context menu for adding Comments.
 */
private static void initAddCommentMenu() {
    ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");

    addCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.add_comment"));
    addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
    addCommentItem.addActionListener(rndBlockMenu);
    addCommentMenu.add(addCommentItem);

    cloneItem1 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
    cloneItem1.setActionCommand(CLONE_BLOCK);
    cloneItem1.addActionListener(rndBlockMenu);
    addCommentMenu.add(cloneItem1);

    addCommentMenuInit = true;

}
项目:Ardublock-for-Dwenguino    文件:ContextMenu.java   
/**
 * Initializes the context menu for deleting Comments.
 */
private static void initRemoveCommentMenu() {
    ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");

    removeCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.delete_comment"));
    removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
    removeCommentItem.addActionListener(rndBlockMenu);

    removeCommentMenu.add(removeCommentItem);
    //rndBlockMenu.add(runBlockItem);


    cloneItem2 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
    cloneItem2.setActionCommand(CLONE_BLOCK);
    cloneItem2.addActionListener(rndBlockMenu);
    removeCommentMenu.add(cloneItem2);

    removeCommentMenuInit = true;
}
项目:SE-410-Project    文件:LangToolMain.java   
private PopupMenu makePopupMenu() {
    final PopupMenu popup = new PopupMenu();
    final ActionListener rmbListener = new TrayActionRMBListener();
    // Check clipboard text:
    final MenuItem checkClipboardItem = new MenuItem(
            StringTools.getLabel(messages
                    .getString("guiMenuCheckClipboard")));
    checkClipboardItem.addActionListener(rmbListener);
    popup.add(checkClipboardItem);
    // Open main window:
    final MenuItem restoreItem = new MenuItem(StringTools.getLabel(messages
            .getString("guiMenuShowMainWindow")));
    restoreItem.addActionListener(rmbListener);
    popup.add(restoreItem);
    // Exit:
    final MenuItem exitItem = new MenuItem(StringTools.getLabel(messages
            .getString("guiMenuQuit")));
    exitItem.addActionListener(rmbListener);
    popup.add(exitItem);
    return popup;
}
项目:wwwa    文件:AWTExample.java   
public static void main(String[] args) {

    Container container = new Container();
    Panel panel = new Panel();
    Menu menu = new Menu();             //!!! its not component
    TextField textField = new TextField();
    container.add(textField);

    Window win = new Window(null);
    win.pack();


    menu.setShortcut(new MenuShortcut(12));
    new MenuItem("label", new MenuShortcut(33, true));

    Menu file = new Menu("File"); 
    MenuItem print; 
    file.add(print = new MenuItem("Print", new MenuShortcut('p'))); 

}
项目:loli.io    文件:SwingSystemMenu.java   
private PopupMenu generateMenu() {
    // 创建弹出菜单
    PopupMenu popup = new PopupMenu();
    // 以下将各个菜单项加入到弹出菜单中
    MenuItem full = new MenuItem("全屏截图");
    full.addActionListener(listener);
    popup.add(full);
    MenuItem select = new MenuItem("选择截图");
    select.addActionListener(listener);
    popup.add(select);
    MenuItem settings = new MenuItem("设置");
    settings.addActionListener(listener);
    popup.add(settings);
    MenuItem quit = new MenuItem("退出");
    quit.addActionListener(listener);
    popup.add(quit);
    return popup;
}
项目:Pegasus    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:Sources-Jeu    文件:IconeTaches.java   
private IconeTaches() {
    super(Images.get("divers/icone.png", true), TITRE);
    setImageAutoSize(true);
    setPopupMenu(menu = new PopupMenu("Menu"));
    menu.add(quitter = new MenuItem("Quitter"));
    menu.add(infos = new MenuItem("A propos..."));
    menu.add(admin = new MenuItem("Administrer"));
    menu.addSeparator();
    menu.add(d3d = new MenuItem("Dessin 3D"));
    menu.add(d2d = new MenuItem("Dessin 2D"));
    quitter.addActionListener(this);
    infos.addActionListener(this);
    admin.addActionListener(this);
    d3d.addActionListener(this);
    d2d.addActionListener(this);
    if(SystemTray.isSupported()) try {
        SystemTray.getSystemTray().add(this);
    } catch(AWTException e) {
        e.printStackTrace();
    }
}
项目:cn1    文件:IMManager.java   
private void show(Component origin, InputMethodContext imc) {
    imContext = imc;

    for (int i = 0; i < getItemCount(); i++) {
        MenuItem item = getItem(i);
        if (!(item instanceof IMSubmenu)) {
            // skip all non-menu elements, such as separators
            continue;
        }
        IMSubmenu subMenu = (IMSubmenu) item;
        InputMethodDescriptor desc = subMenu.getDesc();
        if (desc == null) {
            continue;
        }
        if (desc.hasDynamicLocaleList()) {                    
            subMenu.removeAll();
            subMenu.addLocales();
        }
        subMenu.checkItems();
        i++;
    }
    show(origin, 50, 50);
}
项目:javafx-demos    文件:TrayLeftClick.java   
protected static PopupMenu createPopupMenu() {
    final PopupMenu popup = new PopupMenu();
    MenuItem aboutItem = new MenuItem("About");
    CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
    CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
    Menu displayMenu = new Menu("Display");
    MenuItem errorItem = new MenuItem("Error");
    MenuItem warningItem = new MenuItem("Warning");
    MenuItem infoItem = new MenuItem("Info");
    MenuItem noneItem = new MenuItem("None");
    MenuItem exitItem = new MenuItem("Exit");
    // Add components to pop-up menu
    popup.add(aboutItem);
    popup.addSeparator();
    popup.add(cb1);
    popup.add(cb2);
    popup.addSeparator();
    popup.add(displayMenu);
    displayMenu.add(errorItem);
    displayMenu.add(warningItem);
    displayMenu.add(infoItem);
    displayMenu.add(noneItem);
    popup.add(exitItem);
    return popup;
}
项目:ArduBlock    文件:ContextMenu.java   
/**
 * Initializes the context menu for adding Comments.
 */
private static void initAddCommentMenu() {
    ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");

    addCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.add_comment"));
    addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
    addCommentItem.addActionListener(rndBlockMenu);
    addCommentMenu.add(addCommentItem);

    cloneItem1 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
    cloneItem1.setActionCommand(CLONE_BLOCK);
    cloneItem1.addActionListener(rndBlockMenu);
    addCommentMenu.add(cloneItem1);

    addCommentMenuInit = true;

}
项目:ArduBlock    文件:ContextMenu.java   
/**
 * Initializes the context menu for deleting Comments.
 */
private static void initRemoveCommentMenu() {
    ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");

    removeCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.delete_comment"));
    removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
    removeCommentItem.addActionListener(rndBlockMenu);

    removeCommentMenu.add(removeCommentItem);
    //rndBlockMenu.add(runBlockItem);


    cloneItem2 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
    cloneItem2.setActionCommand(CLONE_BLOCK);
    cloneItem2.addActionListener(rndBlockMenu);
    removeCommentMenu.add(cloneItem2);

    removeCommentMenuInit = true;
}
项目:freeVM    文件:IMManager.java   
private void show(Component origin, InputMethodContext imc) {
    imContext = imc;

    for (int i = 0; i < getItemCount(); i++) {
        MenuItem item = getItem(i);
        if (!(item instanceof IMSubmenu)) {
            // skip all non-menu elements, such as separators
            continue;
        }
        IMSubmenu subMenu = (IMSubmenu) item;
        InputMethodDescriptor desc = subMenu.getDesc();
        if (desc == null) {
            continue;
        }
        if (desc.hasDynamicLocaleList()) {                    
            subMenu.removeAll();
            subMenu.addLocales();
        }
        subMenu.checkItems();
        i++;
    }
    show(origin, 50, 50);
}
项目:freeVM    文件:IMManager.java   
private void show(Component origin, InputMethodContext imc) {
    imContext = imc;

    for (int i = 0; i < getItemCount(); i++) {
        MenuItem item = getItem(i);
        if (!(item instanceof IMSubmenu)) {
            // skip all non-menu elements, such as separators
            continue;
        }
        IMSubmenu subMenu = (IMSubmenu) item;
        InputMethodDescriptor desc = subMenu.getDesc();
        if (desc == null) {
            continue;
        }
        if (desc.hasDynamicLocaleList()) {                    
            subMenu.removeAll();
            subMenu.addLocales();
        }
        subMenu.checkItems();
        i++;
    }
    show(origin, 50, 50);
}
项目:Mobile-Network-LTE    文件:DatabaseManager.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) + "...";
        }

        MenuItem item = new MenuItem(s);

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

        iRecent = (iRecent + 1) % iMaxRecent;
    }
项目:jmg    文件:StaveActionHandler.java   
StaveActionHandler(Stave stave) {
theApp = stave;

      noteContextMenu = new PopupMenu();

      editNote = new MenuItem("Edit Note");
      editNote.addActionListener(this);
      noteContextMenu.add(editNote );       

      repeatNote = new MenuItem("Repeat Note");
      repeatNote.addActionListener(this);
      noteContextMenu.add(repeatNote );         

      makeRest = new MenuItem("Change to Rest");
      makeRest.addActionListener(this);
      noteContextMenu.add(makeRest);       

      deleteNote = new MenuItem("Delete Note");
      deleteNote.addActionListener(this);
      noteContextMenu.add(deleteNote );       

      theApp.add(noteContextMenu);
  }
项目:mkRemote    文件:TrayIconDefinition.java   
public TrayIcon buildTrayIcon() throws IOException {
    PopupMenu popup = new PopupMenu();
    for (MenuItemDefinition mid : menuItems) {
        if (mid instanceof SeperatorMenuItem) {
            popup.addSeparator();
        } else {
            MenuItem item = new MenuItem();
            item.setLabel(mid.getText());
            item.addActionListener(mid);
            popup.add(item);
        }
    }

    TrayIcon ti = new TrayIcon(getImage(imageName), tooltip, popup);
    ti.setImageAutoSize(true);
    return ti;
}
项目:UploadR    文件:Menu.java   
private void createItems()
{
    ih = new ItemHandler();
    MenuItem info = new MenuItem("(c) UploadR v"+Constants.VERSION +" | shortcuts "+(Constants.KEYS_ENABLED ? "enabled" : "disabled"));
    info.setEnabled(false);
    this.add(info);
    for(byte i=0;i<ItemHandler.items.length;++i)
    {
        if(ItemHandler.items[i][0].equals("s"))
        {
            this.addSeparator();
            continue;
        }
        MenuItem item = new MenuItem(ItemHandler.items[i][0]);
        item.setActionCommand(ItemHandler.items[i][1]);
        item.addActionListener(ih);
        this.add(item);
    }
}