Example usage for javax.swing JMenu addSeparator

List of usage examples for javax.swing JMenu addSeparator

Introduction

In this page you can find the example usage for javax.swing JMenu addSeparator.

Prototype

public void addSeparator() 

Source Link

Document

Appends a new separator to the end of the menu.

Usage

From source file:org.rdv.ui.MainPanel.java

private void initMenuBar() {
    Application application = RDV.getInstance();
    ApplicationContext context = application.getContext();

    ResourceMap resourceMap = context.getResourceMap();
    String platform = resourceMap.getString("platform");
    boolean isMac = (platform != null && platform.equals("osx"));

    ActionFactory actionFactory = ActionFactory.getInstance();

    Actions actions = Actions.getInstance();
    ActionMap actionMap = context.getActionMap(actions);

    menuBar = new JMenuBar();

    JMenuItem menuItem;/*from w w  w.  j  a  va2 s. c  om*/

    JMenu fileMenu = new JMenu(fileAction);

    menuItem = new JMenuItem(connectAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(disconnectAction);
    fileMenu.add(menuItem);

    fileMenu.addSeparator();

    menuItem = new JMenuItem(loginAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(logoutAction);
    fileMenu.add(menuItem);

    fileMenu.addMenuListener(new MenuListener() {
        public void menuCanceled(MenuEvent arg0) {
        }

        public void menuDeselected(MenuEvent arg0) {
        }

        public void menuSelected(MenuEvent arg0) {
            if (AuthenticationManager.getInstance().getAuthentication() == null) {
                loginAction.setEnabled(true);
                logoutAction.setEnabled(false);
            } else {
                loginAction.setEnabled(false);
                logoutAction.setEnabled(true);
            }
        }
    });

    fileMenu.addSeparator();

    menuItem = new JMenuItem(loadAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(saveAction);
    fileMenu.add(menuItem);

    fileMenu.addSeparator();

    fileMenu.add(new JMenuItem(actionMap.get("addLocalChannel")));

    fileMenu.addSeparator();

    JMenu importSubMenu = new JMenu(importAction);

    menuItem = new JMenuItem(actionFactory.getDataImportAction());
    importSubMenu.add(menuItem);

    menuItem = new JMenuItem(actionFactory.getOpenSeesDataImportAction());
    importSubMenu.add(menuItem);

    importSubMenu.add(new JMenuItem(actionMap.get("importJPEGs")));

    fileMenu.add(importSubMenu);

    JMenu exportSubMenu = new JMenu(exportAction);

    menuItem = new JMenuItem(actionFactory.getDataExportAction());
    exportSubMenu.add(menuItem);

    menuItem = new JMenuItem(exportVideoAction);
    exportSubMenu.add(menuItem);

    fileMenu.add(exportSubMenu);

    fileMenu.addSeparator();

    menuItem = new DataViewerCheckBoxMenuItem(actionFactory.getOfflineAction());
    fileMenu.add(menuItem);

    if (!isMac) {
        menuItem = new JMenuItem(exitAction);
        fileMenu.add(menuItem);
    }

    menuBar.add(fileMenu);

    JMenu controlMenu = new JMenu(controlAction);

    menuItem = new SelectableCheckBoxMenuItem(realTimeAction);
    controlMenu.add(menuItem);

    menuItem = new SelectableCheckBoxMenuItem(playAction);
    controlMenu.add(menuItem);

    menuItem = new SelectableCheckBoxMenuItem(pauseAction);
    controlMenu.add(menuItem);

    controlMenu.addMenuListener(new MenuListener() {
        public void menuCanceled(MenuEvent arg0) {
        }

        public void menuDeselected(MenuEvent arg0) {
        }

        public void menuSelected(MenuEvent arg0) {
            int state = rbnb.getState();
            realTimeAction.setSelected(state == Player.STATE_MONITORING);
            playAction.setSelected(state == Player.STATE_PLAYING);
            pauseAction.setSelected(state == Player.STATE_STOPPED);
        }
    });

    controlMenu.addSeparator();

    menuItem = new JMenuItem(beginningAction);
    controlMenu.add(menuItem);

    menuItem = new JMenuItem(endAction);
    controlMenu.add(menuItem);

    menuItem = new JMenuItem(gotoTimeAction);
    controlMenu.add(menuItem);

    menuBar.add(controlMenu);

    controlMenu.addSeparator();

    menuItem = new JMenuItem(updateChannelListAction);
    controlMenu.add(menuItem);

    controlMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(dropDataAction);
    controlMenu.add(menuItem);

    JMenu viewMenu = new JMenu(viewAction);

    menuItem = new JCheckBoxMenuItem(showChannelListAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showMetadataPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showControlPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showAudioPlayerPanelAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showMarkerPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(showHiddenChannelsAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(hideEmptyTimeAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(fullScreenAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuBar.add(viewMenu);

    JMenu windowMenu = new JMenu(windowAction);

    List<Extension> extensions = dataPanelManager.getExtensions();
    for (final Extension extension : extensions) {
        Action action = new DataViewerAction("Add " + extension.getName(), "", KeyEvent.VK_J) {
            /** serialization version identifier */
            private static final long serialVersionUID = 36998228704476723L;

            public void actionPerformed(ActionEvent ae) {
                try {
                    dataPanelManager.createDataPanel(extension);
                } catch (Exception e) {
                    log.error("Unable to open data panel provided by extension " + extension.getName() + " ("
                            + extension.getID() + ").");
                    e.printStackTrace();
                }
            }
        };

        menuItem = new JMenuItem(action);
        windowMenu.add(menuItem);
    }

    windowMenu.addSeparator();

    menuItem = new JMenuItem(closeAllDataPanelsAction);
    windowMenu.add(menuItem);

    windowMenu.addSeparator();
    JMenu dataPanelSubMenu = new JMenu(dataPanelAction);

    ButtonGroup dataPanelLayoutGroup = new ButtonGroup();

    menuItem = new JRadioButtonMenuItem(dataPanelHorizontalLayoutAction);
    dataPanelSubMenu.add(menuItem);
    dataPanelLayoutGroup.add(menuItem);

    menuItem = new JRadioButtonMenuItem(dataPanelVerticalLayoutAction);
    menuItem.setSelected(true);
    dataPanelSubMenu.add(menuItem);
    dataPanelLayoutGroup.add(menuItem);
    windowMenu.add(dataPanelSubMenu);

    menuBar.add(windowMenu);

    JMenu helpMenu = new JMenu(helpAction);

    menuItem = new JMenuItem(usersGuideAction);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem(supportAction);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem(releaseNotesAction);
    helpMenu.add(menuItem);

    if (!isMac) {
        helpMenu.addSeparator();

        menuItem = new JMenuItem(aboutAction);
        helpMenu.add(menuItem);
    }

    menuBar.add(helpMenu);

    menuBar.add(Box.createHorizontalGlue());
    throbberStop = DataViewer.getIcon("icons/throbber.png");
    throbberAnim = DataViewer.getIcon("icons/throbber_anim.gif");
    throbber = new JLabel(throbberStop);
    throbber.setBorder(new EmptyBorder(0, 0, 0, 4));
    menuBar.add(throbber, BorderLayout.EAST);

    if (isMac) {
        registerMacOSXEvents();
    }

    frame.setJMenuBar(menuBar);
}

From source file:org.rimudb.editor.RimuDBEditor.java

public JMenuBar buildJMenuBar() {
    log.debug("buildJMenuBar()");
    JMenuBar menuBar = new JMenuBar();

    // File menu/*from  w w w. j  a  va  2 s .  c o  m*/
    JMenu menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);

    openMenuItem = new JMenuItem(
            new OpenDescriptorAction(this, "Open...", loadIcon("/images/famfamfam/folder.png")));
    openMenuItem.setName("OpenMenuItem");
    openMenuItem.setMnemonic(KeyEvent.VK_O);
    openMenuItem.setAccelerator(
            KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
    menu.add(openMenuItem);

    saveMenuItem = new JMenuItem(
            new SaveDescriptorAction(this, "Save", loadIcon("/images/famfamfam/disk.png")));
    saveMenuItem.setName("SaveMenuItem");
    saveMenuItem.setMnemonic(KeyEvent.VK_S);
    saveMenuItem.setAccelerator(
            KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
    menu.add(saveMenuItem);

    saveAsMenuItem = new JMenuItem(new SaveAsDescriptorAction(this, "Save as..."));
    saveAsMenuItem.setName("SaveAsMenuItem");
    menu.add(saveAsMenuItem);

    menu.addSeparator();

    clearMenuItem = new JMenuItem(
            new ClearTableAction(this, "Clear...", loadIcon("/images/famfamfam/bin_closed.png")));
    clearMenuItem.setName("ClearMenuItem");
    clearMenuItem.setMnemonic(KeyEvent.VK_C);
    menu.add(clearMenuItem);

    preferencesMenuItem = new JMenuItem(
            new PreferencesAction(this, "Preferences...", loadIcon("/images/famfamfam/text_list_bullets.png")));
    preferencesMenuItem.setName("PreferencesMenuItem");
    preferencesMenuItem.setEnabled(false);
    preferencesMenuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(preferencesMenuItem);

    menu.addSeparator();

    exitMenuItem = new JMenuItem(new ExitAction(this, "Exit"));
    exitMenuItem.setName("ExitMenuItem");
    exitMenuItem.setMnemonic(KeyEvent.VK_E);
    menu.add(exitMenuItem);

    menuBar.add(menu);

    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);

    dbImportMenuItem = new JMenuItem(
            new ImportAction(this, "Import from database...", loadIcon("/images/famfamfam/database_go.png")));
    dbImportMenuItem.setName("DbImportMenuItem");
    dbImportMenuItem.setEnabled(false);
    dbImportMenuItem.setMnemonic(KeyEvent.VK_I);
    dbImportMenuItem.setAccelerator(
            KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
    toolsMenu.add(dbImportMenuItem);

    createClassesMenuItem = new JMenuItem(new GenerateJavaAction(this, "Create classes...",
            loadIcon("/images/famfamfam/page_white_cup.png")));
    createClassesMenuItem.setName("CreateClassesMenuItem");
    createClassesMenuItem.setMnemonic(KeyEvent.VK_C);
    toolsMenu.add(createClassesMenuItem);

    ddsExportMenuItem = new JMenuItem("Export as DDS...");
    ddsExportMenuItem.setName("DdsExportMenuItem");
    ddsExportMenuItem.setMnemonic(KeyEvent.VK_D);
    ddsExportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            actionExportToDDS();
        }
    });
    toolsMenu.add(ddsExportMenuItem);

    sqlExportMenuItem = new JMenuItem("Export as SQL...");
    sqlExportMenuItem.setIcon(loadIcon("/images/famfamfam/page_white_database.png"));
    sqlExportMenuItem.setName("SqlExportMenuItem");
    sqlExportMenuItem.setMnemonic(KeyEvent.VK_Q);
    sqlExportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            actionExportToSQL();
        }
    });
    toolsMenu.add(sqlExportMenuItem);

    toolsMenu.addSeparator();

    propertyRenameMenuItem = new JMenuItem("Rename Properties...");
    propertyRenameMenuItem.setName("PropertyRenameMenuItem");
    propertyRenameMenuItem.setMnemonic(KeyEvent.VK_R);
    propertyRenameMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            actionRenameProperties();
        }
    });
    toolsMenu.add(propertyRenameMenuItem);

    copyCodeMenuItem = new JMenuItem(new GenerateCopyCodeAction(this, "Create Java DO Copy Code...", null));
    copyCodeMenuItem.setName("CopyCodeMenuItem");
    toolsMenu.add(copyCodeMenuItem);

    convertFinderMenuItem = new JMenuItem(new ConvertFinderAction(this, "Convert Finders (pre 1.1)...", null));
    convertFinderMenuItem.setName("ConvertFinderMenuItem");
    toolsMenu.add(convertFinderMenuItem);

    convertCDBMenuItem = new JMenuItem(new ConvertCDBAction(this, "Convert CDB Configs (pre 1.2)...", null));
    convertCDBMenuItem.setName("ConvertCDBMenuItem");
    toolsMenu.add(convertCDBMenuItem);

    menuBar.add(toolsMenu);

    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);

    aboutMenuItem = new JMenuItem(new AboutAction(this, "About..."));
    aboutMenuItem.setName("AboutMenuItem");
    helpMenu.add(aboutMenuItem);

    menuBar.add(helpMenu);

    return menuBar;
}

From source file:org.rvsnoop.ui.RvSnoopApplication.java

private JMenu createHelpMenu() {
    JMenu helpMenu = new JMenu();
    helpMenu.setName("helpMenu");
    getContext().getResourceMap().injectComponent(helpMenu);
    ApplicationActionMap actionMap = getContext().getActionMap();
    helpMenu.add(actionMap.get("displayHelp"));
    helpMenu.add(actionMap.get("displayHomePage"));
    helpMenu.add(actionMap.get("displayBugsPage"));
    helpMenu.addSeparator();
    helpMenu.add(actionMap.get("checkForUpdates"));
    helpMenu.addSeparator();// w w w.j av  a2s  .  c  o m
    helpMenu.add(actionMap.get("displayLicense"));
    helpMenu.add(actionMap.get("displayAbout"));
    return helpMenu;
}

From source file:org.rvsnoop.ui.RvSnoopApplication.java

@Override
protected void startup() {
    setMainFrame(injector.getInstance(Application.class).getFrame());

    final JFrame frame = getMainFrame();
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new FrameClosingListener());
    addExitListener(new MaybeExit());

    ApplicationActionMap actionMap = getContext().getActionMap();
    JMenu fileMenu = frame.getJMenuBar().getMenu(0);
    fileMenu.addSeparator();
    fileMenu.add(actionMap.get("quit"));

    frame.getJMenuBar().add(createHelpMenu());
    getContext().getResourceMap().injectComponents(frame);

    if (AppHelper.getPlatform() == PlatformType.OS_X) {
        configureMacOsEventHandlers();/* ww w .  j a  v a 2  s .  c o  m*/
    }

    if (initialProjectFile == null) {
        final JFileChooser chooser = new JFileChooser();
        chooser.setFileFilter(new ProjectFileFilter());
        final int option = chooser.showDialog(null, "Open Project");
        initialProjectFile = chooser.getSelectedFile();
        if (JFileChooser.APPROVE_OPTION != option || initialProjectFile == null) {
            exit();
        }

    }
    show(frame);
    injector.getInstance(ProjectService.class).openProject(initialProjectFile);
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Create the application.//from ww  w .j ava 2 s .c o  m
 * 
 * @param name
 *          the name
 */
public MainWindow(String name) {
    super(name);
    setName("mainWindow");
    setMinimumSize(new Dimension(1000, 700));

    instance = this;

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnTmm = new JMenu("tinyMediaManager");
    mnTmm.setMnemonic(KeyEvent.VK_T);
    menuBar.add(mnTmm);

    if (!Globals.isDonator()) {
        mnTmm.add(new RegisterDonatorVersionAction());
    }

    mnTmm.add(new SettingsAction());
    mnTmm.addSeparator();
    mnTmm.add(new LaunchUpdaterAction());
    mnTmm.addSeparator();
    mnTmm.add(new ExitAction());
    initialize();

    // tools menu
    JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$
    tools.setMnemonic(KeyEvent.VK_O);
    tools.add(new ClearDatabaseAction());

    JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$
    cache.setMnemonic(KeyEvent.VK_C);
    tools.add(cache);
    JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction());
    clearImageCache.setMnemonic(KeyEvent.VK_I);
    cache.add(clearImageCache);

    JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction());
    rebuildImageCache.setMnemonic(KeyEvent.VK_R);
    cache.add(rebuildImageCache);

    JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$
    tmmFolder.setMnemonic(KeyEvent.VK_I);
    tools.add(tmmFolder);
    tmmFolder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path path = Paths.get(System.getProperty("user.dir"));
            try {
                // check whether this location exists
                if (Files.exists(path)) {
                    TmmUIHelper.openFile(path);
                }
            } catch (Exception ex) {
                LOGGER.error("open filemanager", ex);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path,
                        "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() }));
            }
        }
    });

    JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$
    tmmLogs.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmLogs);
    tmmLogs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog logDialog = new LogDialog();
            logDialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            logDialog.setVisible(true);
        }
    });

    JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$
    tmmMessages.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmMessages);
    tmmMessages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog messageDialog = MessageHistoryDialog.getInstance();
            messageDialog.setVisible(true);
        }
    });

    tools.addSeparator();
    final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$
    menuWakeOnLan.setMnemonic(KeyEvent.VK_W);
    menuWakeOnLan.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuWakeOnLan.removeAll();
            for (final WolDevice device : Globals.settings.getWolDevices()) {
                JMenuItem item = new JMenuItem(device.getName());
                item.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        Utils.sendWakeOnLanPacket(device.getMacAddress());
                    }
                });
                menuWakeOnLan.add(item);
            }
        }
    });
    tools.add(menuWakeOnLan);

    // activate/deactivate WakeOnLan menu item
    tools.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            if (Globals.settings.getWolDevices().size() > 0) {
                menuWakeOnLan.setEnabled(true);
            } else {
                menuWakeOnLan.setEnabled(false);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    if (Globals.isDebug()) {
        final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$

        JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$
        trace.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
                lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE);
                MessageManager.instance.pushMessage(new Message("Trace levels set!", ""));
                LOGGER.trace("if you see that, we're now on TRACE logging level ;)");
            }
        });

        debugMenu.add(trace);
        tools.add(debugMenu);
    }

    menuBar.add(tools);

    mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_C);
    mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B);
    menuBar.add(mnTmm);

    mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_H);
    menuBar.add(mnTmm);

    mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W);
    mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O);
    mnTmm.addSeparator();

    mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A);

    menuBar.add(Box.createGlue());

    if (!Globals.isDonator()) {
        JButton btnDonate = new JButton(new DonateAction());
        btnDonate.setBorderPainted(false);
        btnDonate.setFocusPainted(false);
        btnDonate.setContentAreaFilled(false);
        menuBar.add(btnDonate);
    }

    checkForUpdate();
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

private void buildMenu() {
    menu.setMnemonic(KeyEvent.VK_M);

    // menu items
    JMenuItem menuItem = menu.add(actionUpdateDataSources2);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(/*from  w  w  w.j a v  a  2  s.com*/
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$
    menuUpdateDatasources.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuUpdateDatasources.removeAll();
            menuFindMissingMovies.removeAll();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds));
                menuUpdateDatasources.add(item);

                item = new JMenuItem(new MovieFindMissingAction(ds));
                menuFindMissingMovies.add(item);

            }
        }
    });
    menu.add(menuUpdateDatasources);

    menu.add(new MovieFindMissingAction());
    menu.add(menuFindMissingMovies);
    menu.add(new MovieCreateOfflineAction(true));

    menu.addSeparator();

    JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
    menuScrape.setMnemonic(KeyEvent.VK_S);
    menuItem = menuScrape.add(actionScrape2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeSelected);
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeUnscraped);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeMetadataSelected);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuScrape.add(actionAssignMovieSets);
    menu.add(menuScrape);

    JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$
    menuEdit.setMnemonic(KeyEvent.VK_E);
    menuItem = menuEdit.add(actionEditMovie2);
    menuItem.setMnemonic(KeyEvent.VK_E);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionBatchEdit);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionSetWatchedFlag);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRename2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRenamerPreview);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(menuEdit);

    menuItem = menu.add(actionRewriteNfo);
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem = menu.add(actionTrailerDownload);
    menuItem = menu.add(actionSearchSubtitle);
    menuItem = menu.add(actionDownloadSubtitle);

    menu.addSeparator();
    menuItem = menu.add(actionMediaInformation2);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionExport);
    menuItem.setMnemonic(KeyEvent.VK_X);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionRemove2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE));
    menuItem = menu.add(actionDelete2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));
    menu.addSeparator();
    menuItem = menu.add(actionSyncTrakt);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem = menu.add(actionSyncWatchedTrakt);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem = menu.add(actionSyncSelectedTrakt);

    menu.addSeparator();
    menuItem = menu.add(actionClearImageCache);
    menuItem.setMnemonic(KeyEvent.VK_C);

    // popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(actionScrape2);
    popupMenu.add(actionScrapeSelected);
    popupMenu.add(actionScrapeUnscraped);
    popupMenu.add(actionScrapeMetadataSelected);
    popupMenu.add(actionAssignMovieSets);
    popupMenu.addSeparator();
    popupMenu.add(actionEditMovie2);
    popupMenu.add(actionBatchEdit);
    popupMenu.add(actionSetWatchedFlag);
    popupMenu.add(actionRewriteNfo);
    popupMenu.add(actionRename2);
    popupMenu.add(actionRenamerPreview);
    popupMenu.add(actionMediaInformation2);
    popupMenu.add(actionExport);
    popupMenu.add(actionTrailerDownload);
    popupMenu.add(actionSearchSubtitle);
    popupMenu.add(actionDownloadSubtitle);
    popupMenu.addSeparator();
    popupMenu.add(actionSyncTrakt);
    popupMenu.add(actionSyncWatchedTrakt);
    popupMenu.add(actionSyncSelectedTrakt);
    popupMenu.addSeparator();
    popupMenu.add(actionClearImageCache);
    popupMenu.addSeparator();
    popupMenu.add(actionRemove2);
    popupMenu.add(actionDelete2);

    if (Globals.isDebug()) {
        JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$
        menuDebug.add(debugDumpMovie);
        menuDebug.addSeparator();
        menuDebug.add(new FakeTmmTaskAction("download", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("download", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10));
        popupMenu.add(menuDebug);
    }

    MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table);
    table.addMouseListener(mouseListener);
}

From source file:org.wmediumd.WmediumdGraphView.java

public WmediumdGraphView() {

    JMenuBar menuBar;//  w  ww .  ja va  2 s . co m
    JMenu menu;
    JMenuItem menuItem;

    setup();
    setupVisualization();
    setupMouse();

    // Let's add a menu for changing mouse modes
    menuBar = new JMenuBar();

    menu = new JMenu();
    menu.setText("File");
    menu.setIcon(null);

    menuItem = new JMenuItem("New file");
    menuItem.setIcon(UIManager.getIcon("FileView.fileIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            // TODO Use the Factory
            MyNode.nodeCount = 0;
            MyLink.linkCount = 0;
            graph.clear();
            frame.repaint();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem("Load file");
    menuItem.setIcon(UIManager.getIcon("FileChooser.upFolderIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            FileChooserLoad fl = new FileChooserLoad();
            if (fl.getMatrixList().rates() == MyLink.rates) {
                MyNode.nodeCount = 0;
                MyLink.linkCount = 0;
                graph.clear();
                graph.setDataFromMatrixList(fl.getMatrixList());
                frame.repaint();
            }

        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem("Save as...");
    menuItem.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (MyNode.nodeCount > 1) {
                System.out.println(generateConfigString());
                new FileChooserSave(generateConfigString());
            }
        }
    });
    menu.add(menuItem);

    menu.addSeparator();
    menuItem = new JMenuItem("Exit");
    menuItem.setIcon(UIManager.getIcon("InternalFrame.closeIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            System.exit(0);
        }
    });
    menu.add(menuItem);
    menuBar.add(menu);

    menu = graphMouse.getModeMenu(); // Obtain mode menu from the mouse
    menu.setText("Edit");
    menu.setIcon(null); // I'm using this in a main menu
    menu.setPreferredSize(new Dimension(40, 15)); // Change the size
    menuBar.add(menu);

    menu = new JMenu("Help");

    menuItem = new JMenuItem("Help");
    menuItem.setIcon(UIManager.getIcon("FileChooser.detailsViewIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            openURL("http://o11s.org/trac/wiki/MeshTestingWmediumd#a4.1.Usingwconfig");
        }
    });
    menu.add(menuItem);
    menu.addSeparator();

    menuItem = new JMenuItem("About");
    menuItem.setIcon(UIManager.getIcon("FileChooser.homeFolderIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {

            JOptionPane.showMessageDialog(
                    frame, "Wireless medium daemon\n" + "configuration tool <v0.2b>\n\n"
                            + "(C) 2011 - Javier Lopez\n" + "<jlopex@gmail.com>\n",
                    "About", JOptionPane.INFORMATION_MESSAGE);

        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
    vViewer.setGraphMouse(graphMouse);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(vViewer);
    frame.pack();
    frame.setVisible(true);
}

From source file:processing.app.Base.java

protected void rebuildToolbarMenu(JMenu menu) {
    JMenuItem item;//from  w w w.  j ava  2 s  . co m
    menu.removeAll();

    // Add the single "Open" item
    item = Editor.newJMenuItem(tr("Open..."), 'O');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                handleOpenPrompt();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    menu.add(item);
    menu.addSeparator();

    // Add a list of all sketches and subfolders
    boolean sketches = addSketches(menu, BaseNoGui.getSketchbookFolder());
    if (sketches)
        menu.addSeparator();

    // Add each of the subfolders of examples directly to the menu
    boolean found = addSketches(menu, BaseNoGui.getExamplesFolder());
    if (found)
        menu.addSeparator();
}

From source file:processing.app.Base.java

public void rebuildImportMenu(JMenu importMenu) {
    if (importMenu == null)
        return;/*from   www.j  a v a 2  s . co m*/
    importMenu.removeAll();

    JMenuItem menu = new JMenuItem(tr("Manage Libraries..."));
    // Ctrl+Shift+I on Windows and Linux, Command+Shift+I on macOS
    menu.setAccelerator(KeyStroke.getKeyStroke('I',
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK));
    menu.addActionListener(e -> openLibraryManager("", ""));
    importMenu.add(menu);
    importMenu.addSeparator();

    JMenuItem addLibraryMenuItem = new JMenuItem(tr("Add .ZIP Library..."));
    addLibraryMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Base.this.handleAddLibrary();
            BaseNoGui.librariesIndexer.rescanLibraries();
            Base.this.onBoardOrPortChange();
            Base.this.rebuildImportMenu(Editor.importMenu);
            Base.this.rebuildExamplesMenu(Editor.examplesMenu);
        }
    });
    importMenu.add(addLibraryMenuItem);
    importMenu.addSeparator();

    // Split between user supplied libraries and IDE libraries
    TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();

    if (targetPlatform != null) {
        LibraryList libs = getSortedLibraries();
        String lastLibType = null;
        for (UserLibrary lib : libs) {
            String libType = lib.getTypes().get(0);
            if (!libType.equals(lastLibType)) {
                if (lastLibType != null) {
                    importMenu.addSeparator();
                }
                lastLibType = libType;
                JMenuItem platformItem = new JMenuItem(I18n.format(tr("{0} libraries"), tr(lastLibType)));
                platformItem.setEnabled(false);
                importMenu.add(platformItem);
            }

            AbstractAction action = new AbstractAction(lib.getName()) {
                public void actionPerformed(ActionEvent event) {
                    UserLibrary l = (UserLibrary) getValue("library");
                    try {
                        activeEditor.getSketchController().importLibrary(l);
                    } catch (IOException e) {
                        showWarning(tr("Error"),
                                I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
                    }
                }
            };
            action.putValue("library", lib);

            // Add new element at the bottom
            JMenuItem item = new JMenuItem(action);
            item.putClientProperty("library", lib);
            importMenu.add(item);
        }
    }
}

From source file:processing.app.Base.java

public void rebuildExamplesMenu(JMenu menu) {
    if (menu == null) {
        return;/*from  ww  w .ja  va2  s  .c  o m*/
    }

    menu.removeAll();

    // Add examples from distribution "example" folder
    JMenuItem label = new JMenuItem(tr("Built-in Examples"));
    label.setEnabled(false);
    menu.add(label);
    boolean found = addSketches(menu, BaseNoGui.getExamplesFolder());
    if (found) {
        menu.addSeparator();
    }

    // Libraries can come from 4 locations: collect info about all four
    String boardId = null;
    String referencedPlatformName = null;
    String myArch = null;
    TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
    if (targetPlatform != null) {
        myArch = targetPlatform.getId();
        boardId = BaseNoGui.getTargetBoard().getName();
        String core = BaseNoGui.getBoardPreferences().get("build.core", "arduino");
        if (core.contains(":")) {
            String refcore = core.split(":")[0];
            TargetPlatform referencedPlatform = BaseNoGui.getTargetPlatform(refcore, myArch);
            if (referencedPlatform != null) {
                referencedPlatformName = referencedPlatform.getPreferences().get("name");
            }
        }
    }

    // Divide the libraries into 7 lists, corresponding to the 4 locations
    // with the retired IDE libs further divided into their own list, and
    // any incompatible sketchbook libs further divided into their own list.
    // The 7th list of "other" libraries should always be empty, but serves
    // as a safety feature to prevent any library from vanishing.
    LibraryList allLibraries = BaseNoGui.librariesIndexer.getInstalledLibraries();
    LibraryList ideLibs = new LibraryList();
    LibraryList retiredIdeLibs = new LibraryList();
    LibraryList platformLibs = new LibraryList();
    LibraryList referencedPlatformLibs = new LibraryList();
    LibraryList sketchbookLibs = new LibraryList();
    LibraryList sketchbookIncompatibleLibs = new LibraryList();
    LibraryList otherLibs = new LibraryList();
    for (UserLibrary lib : allLibraries) {
        // Get the library's location - used for sorting into categories
        Location location = lib.getLocation();
        // Is this library compatible?
        List<String> arch = lib.getArchitectures();
        boolean compatible;
        if (myArch == null || arch == null || arch.contains("*")) {
            compatible = true;
        } else {
            compatible = arch.contains(myArch);
        }
        // IDE Libaries (including retired)
        if (location == Location.IDE_BUILTIN) {
            if (compatible) {
                // only compatible IDE libs are shown
                if (lib.getTypes().contains("Retired")) {
                    retiredIdeLibs.add(lib);
                } else {
                    ideLibs.add(lib);
                }
            }
            // Platform Libraries
        } else if (location == Location.CORE) {
            // all platform libs are assumed to be compatible
            platformLibs.add(lib);
            // Referenced Platform Libraries
        } else if (location == Location.REFERENCED_CORE) {
            // all referenced platform libs are assumed to be compatible
            referencedPlatformLibs.add(lib);
            // Sketchbook Libraries (including incompatible)
        } else if (location == Location.SKETCHBOOK) {
            if (compatible) {
                // libraries promoted from sketchbook (behave as builtin)
                if (!lib.getTypes().isEmpty() && lib.getTypes().contains("Arduino")
                        && lib.getArchitectures().contains("*")) {
                    ideLibs.add(lib);
                } else {
                    sketchbookLibs.add(lib);
                }
            } else {
                sketchbookIncompatibleLibs.add(lib);
            }
            // Other libraries of unknown type (should never occur)
        } else {
            otherLibs.add(lib);
        }
    }

    // Add examples from libraries
    if (!ideLibs.isEmpty()) {
        ideLibs.sort();
        label = new JMenuItem(tr("Examples for any board"));
        label.setEnabled(false);
        menu.add(label);
    }
    for (UserLibrary lib : ideLibs) {
        addSketchesSubmenu(menu, lib);
    }

    if (!retiredIdeLibs.isEmpty()) {
        retiredIdeLibs.sort();
        JMenu retired = new JMenu(tr("RETIRED"));
        menu.add(retired);
        for (UserLibrary lib : retiredIdeLibs) {
            addSketchesSubmenu(retired, lib);
        }
    }

    if (!platformLibs.isEmpty()) {
        menu.addSeparator();
        platformLibs.sort();
        label = new JMenuItem(I18n.format(tr("Examples for {0}"), boardId));
        label.setEnabled(false);
        menu.add(label);
        for (UserLibrary lib : platformLibs) {
            addSketchesSubmenu(menu, lib);
        }
    }

    if (!referencedPlatformLibs.isEmpty()) {
        menu.addSeparator();
        referencedPlatformLibs.sort();
        label = new JMenuItem(I18n.format(tr("Examples for {0}"), referencedPlatformName));
        label.setEnabled(false);
        menu.add(label);
        for (UserLibrary lib : referencedPlatformLibs) {
            addSketchesSubmenu(menu, lib);
        }
    }

    if (!sketchbookLibs.isEmpty()) {
        menu.addSeparator();
        sketchbookLibs.sort();
        label = new JMenuItem(tr("Examples from Custom Libraries"));
        label.setEnabled(false);
        menu.add(label);
        for (UserLibrary lib : sketchbookLibs) {
            addSketchesSubmenu(menu, lib);
        }
    }

    if (!sketchbookIncompatibleLibs.isEmpty()) {
        sketchbookIncompatibleLibs.sort();
        JMenu incompatible = new JMenu(tr("INCOMPATIBLE"));
        menu.add(incompatible);
        for (UserLibrary lib : sketchbookIncompatibleLibs) {
            addSketchesSubmenu(incompatible, lib);
        }
    }

    if (!otherLibs.isEmpty()) {
        menu.addSeparator();
        otherLibs.sort();
        label = new JMenuItem(tr("Examples from Other Libraries"));
        label.setEnabled(false);
        menu.add(label);
        for (UserLibrary lib : otherLibs) {
            addSketchesSubmenu(menu, lib);
        }
    }
}