Example usage for javax.swing JCheckBoxMenuItem setSelected

List of usage examples for javax.swing JCheckBoxMenuItem setSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBoxMenuItem setSelected.

Prototype

public void setSelected(boolean b) 

Source Link

Document

Sets the state of the button.

Usage

From source file:org.omegat.gui.issues.IssuesPanelController.java

JMenuBar generateMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = menuBar.add(new JMenu(OStrings.getString("ISSUES_WINDOW_MENU_OPTIONS")));

    {//from  w  w w.j a v  a2s . co  m
        // Tags item is hard-coded because it is not disableable and is implemented differently from all
        // others.
        JCheckBoxMenuItem tagsItem = new JCheckBoxMenuItem(OStrings.getString(
                "ISSUES_WINDOW_MENU_OPTIONS_TOGGLE_PROVIDER", OStrings.getString("ISSUES_TAGS_PROVIDER_NAME")));
        tagsItem.setSelected(true);
        tagsItem.setEnabled(false);
        menu.add(tagsItem);
    }

    Set<String> disabledProviders = IssueProviders.getDisabledProviderIds();
    IssueProviders.getIssueProviders().stream().sorted(Comparator.comparing(IIssueProvider::getId))
            .forEach(provider -> {
                String label = StringUtil.format(
                        OStrings.getString("ISSUES_WINDOW_MENU_OPTIONS_TOGGLE_PROVIDER"), provider.getName());
                JCheckBoxMenuItem item = new JCheckBoxMenuItem(label);
                item.addActionListener(e -> {
                    IssueProviders.setProviderEnabled(provider.getId(), item.isSelected());
                    refreshData(selectedEntry, selectedType);
                });
                item.setSelected(!disabledProviders.contains(provider.getId()));
                menu.add(item);
            });

    menu.addSeparator();

    {
        JCheckBoxMenuItem askItem = new JCheckBoxMenuItem(OStrings.getString("ISSUES_WINDOW_MENU_DONT_ASK"));
        askItem.setSelected(Preferences.isPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK));
        askItem.addActionListener(
                e -> Preferences.setPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK, askItem.isSelected()));
        menu.add(askItem);
    }
    return menuBar;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java

/**
 * Brings up the <code>ManagePopupMenu</code>on top of the specified
 * component at the specified location.//w  w  w.j  av  a  2 s  .co m
 * 
 * @param c The component that requested the po-pup menu.
 * @param p The point at which to display the menu, relative to the
 *            <code>component</code>'s coordinates.
 */
private void showPersonalMenu(Component c, Point p) {
    if (p == null)
        return;

    if (c == null)
        throw new IllegalArgumentException("No component.");

    personalMenu = new JPopupMenu();
    personalMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    List<GroupSelectionAction> l = controller.getUserGroupAction();
    Iterator<GroupSelectionAction> i = l.iterator();
    GroupSelectionAction a;
    JCheckBoxMenuItem item;
    ButtonGroup buttonGroup = new ButtonGroup();
    long id = model.getGroupId();
    while (i.hasNext()) {
        a = i.next();
        item = new JCheckBoxMenuItem(a);
        item.setEnabled(true);
        item.setSelected(a.isSameGroup(id));
        initMenuItem(item);
        buttonGroup.add(item);
        personalMenu.add(item);
    }
    personalMenu.show(c, p.x, p.y);
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the unit bar sub-menu.
 * //w ww  .  ja va 2 s . c  o m
 * @param pref The user preferences.
 * @return See above.
 */
private JMenu createScaleBarLengthSubMenu(ViewerPreferences pref) {
    scaleBarMenu = new JMenu(SCALE_BAR_TEXT + model.getUnits() + ")");
    scaleBarGroup = new ButtonGroup();
    if (pref != null && pref.getScaleBarIndex() > 0)
        defaultIndex = pref.getScaleBarIndex();
    UnitBarSizeAction a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_ONE);
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(a);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarGroup.add(item);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_TWO);
    item = new JCheckBoxMenuItem(a);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarGroup.add(item);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_FIVE);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_FIVE));
    scaleBarGroup.add(item);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_TEN);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_TEN));
    scaleBarGroup.add(item);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_TWENTY);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_TWENTY));
    scaleBarGroup.add(item);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_FIFTY);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_FIFTY));
    scaleBarGroup.add(item);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_HUNDRED);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_HUNDRED));
    scaleBarGroup.add(item);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarMenu.add(item);
    a = (UnitBarSizeAction) controller.getAction(ImViewerControl.UNIT_BAR_CUSTOM);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.UNIT_BAR_CUSTOM));
    scaleBarGroup.add(item);
    item.setSelected(a.getIndex() == defaultIndex);
    scaleBarMenu.add(item);
    return scaleBarMenu;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Updates UI components when a zooming factor is selected.
 * /*from ww w  . j  a v  a 2  s . c o m*/
 * @param factor   The magnification factor.
 * @param zoomIndex The index of the selected zoomFactor.
 */
void setZoomFactor(double factor, int zoomIndex) {
    setMagnificationStatus(factor, zoomIndex);
    JCheckBoxMenuItem b;
    Enumeration e;
    Action a;
    if (zoomingGroup == null)
        return;
    for (e = zoomingGroup.getElements(); e.hasMoreElements();) {
        b = (JCheckBoxMenuItem) e.nextElement();
        a = b.getAction();
        if (a instanceof ZoomAction) {
            b.removeActionListener(a);
            b.setSelected(((ZoomAction) a).getIndex() == zoomIndex);
            b.setAction(a);
        }
    }
    controlPane.setZoomFactor(zoomIndex);
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/** 
 * Sets the magnification for the grid view.
 * //from  w w w .  j  av a 2 s.  co m
 * @param factor The value to set.
 */
void setGridMagnificationFactor(double factor) {
    if (model.getTabbedIndex() == ImViewer.GRID_INDEX)
        setMagnificationStatus(factor, ZoomAction.getIndex(factor));
    JCheckBoxMenuItem b;
    Enumeration e;
    Action a;
    int zoomIndex = ZoomGridAction.getIndex(factor);
    for (e = zoomingGridGroup.getElements(); e.hasMoreElements();) {
        b = (JCheckBoxMenuItem) e.nextElement();
        a = b.getAction();
        if (a instanceof ZoomGridAction) {
            b.removeActionListener(a);
            b.setSelected(((ZoomGridAction) a).getIndex() == zoomIndex);
            b.setAction(a);
        }
    }
    controlPane.setGridMagnificationFactor((int) (factor * 10));
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java

/**
 * Creates a menu item./*www.  ja va2s . c o m*/
 * 
 * @param index The index associated to the item.
 * @return See above.
 */
private JCheckBoxMenuItem createMenuItem(int index) {
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(NAMES[index]);
    Font f = item.getFont();
    item.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2));
    item.setSelected(filter == index);
    item.addActionListener(this);
    item.setActionCommand("" + index);
    return item;
}

From source file:org.rdv.DockingDataPanelManager.java

/**
 * Creates the menu where individual window bars can be enabled and disabled.
 *
 * @return the window bar menu//w  w w  .ja v  a 2s.  c  o m
 */
private JMenu createWindowBarsMenu() {
    JMenu barsMenu = new JMenu("Window Bars");

    for (int i = 0; i < 4; i++) {
        final Direction d = Direction.getDirections()[i];
        JCheckBoxMenuItem item = new JCheckBoxMenuItem("Toggle " + d);
        item.setSelected(rootWindow_.getWindowBar(d).isEnabled());
        barsMenu.add(item).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // Enable/disable the window bar
                rootWindow_.getWindowBar(d).setEnabled(!rootWindow_.getWindowBar(d).isEnabled());
            }
        });
    }

    return barsMenu;
}

From source file:org.rdv.DockingDataPanelManager.java

/**
 * Creates the menu where the theme can be changed.
 *
 * @return the theme menu/* ww  w  .j a  va 2s  .c om*/
 */
private JMenu createThemesMenu() {
    JMenu themesMenu = new JMenu("Themes");

    // don't get the title bar window thing

    final JCheckBoxMenuItem titleBarStyleItem = new JCheckBoxMenuItem("Title Bar Style Theme");
    titleBarStyleItem.setSelected(titleBarTheme_);
    titleBarStyleItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!titleBarTheme_)
                properties_.addSuperObject(titleBarStyleProperties);
            else {
                // TODO this does not work to remove title bars from windows 
                properties_.removeSuperObject(titleBarStyleProperties);
            }
            titleBarTheme_ = !titleBarTheme_;
        }
    });

    themesMenu.add(titleBarStyleItem);
    themesMenu.add(new JSeparator());

    DockingWindowsTheme[] themes = { new DefaultDockingTheme(), new LookAndFeelDockingTheme(),
            new BlueHighlightDockingTheme(), new SlimFlatDockingTheme(), new GradientDockingTheme(),
            new ShapedGradientDockingTheme(), new SoftBlueIceDockingTheme(), new ClassicDockingTheme() };

    ButtonGroup group = new ButtonGroup();

    for (int i = 0; i < themes.length; i++) {
        final DockingWindowsTheme theme = themes[i];

        JRadioButtonMenuItem item = new JRadioButtonMenuItem(theme.getName());
        item.setSelected(themes[i].getClass() == currentTheme_.getClass());

        group.add(item);

        themesMenu.add(item).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // Clear the modified properties values
                properties_.getMap().clear(true);

                setTheme(theme);
            }
        });
    }
    return themesMenu;
}

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

private void initActions() {
    fileAction = new DataViewerAction("File", "File Menu", KeyEvent.VK_F);

    connectAction = new DataViewerAction("Connect", "Connect to RBNB server", KeyEvent.VK_C,
            KeyStroke.getKeyStroke(KeyEvent.VK_C, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = 5038790506859429244L;

        public void actionPerformed(ActionEvent ae) {
            if (rbnbConnectionDialog == null) {
                rbnbConnectionDialog = new RBNBConnectionDialog(frame, rbnb, dataPanelManager);
            } else {
                rbnbConnectionDialog.setVisible(true);
            }/*from   w ww .ja  v a2s.  co  m*/
        }
    };

    disconnectAction = new DataViewerAction("Disconnect", "Disconnect from RBNB server", KeyEvent.VK_D,
            KeyStroke.getKeyStroke(KeyEvent.VK_D, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -1871076535376405181L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
            rbnb.disconnect();
        }
    };

    loginAction = new DataViewerAction("Login", "Login as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6105503896620555072L;

        public void actionPerformed(ActionEvent ae) {
            if (loginDialog == null) {
                loginDialog = new LoginDialog(frame);
            } else {
                loginDialog.setVisible(true);
            }
        }
    };

    logoutAction = new DataViewerAction("Logout", "Logout as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2517567766044673777L;

        public void actionPerformed(ActionEvent ae) {
            AuthenticationManager.getInstance().setAuthentication(null);
        }
    };

    loadAction = new DataViewerAction("Load Setup", "Load data viewer setup from file") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7197815395398039821L;

        public void actionPerformed(ActionEvent ae) {
            File configFile = UIUtilities.getFile(new RDVConfigurationFileFilter(), "Load");
            if (configFile != null) {
                try {
                    URL configURL = configFile.toURI().toURL();
                    ConfigurationManager.loadConfiguration(configURL);
                } catch (MalformedURLException e) {
                    DataViewer.alertError("\"" + configFile + "\" is not a valid configuration file URL.");
                }
            }
        }
    };

    saveAction = new DataViewerAction("Save Setup", "Save data viewer setup to file") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8259994975940624038L;

        public void actionPerformed(ActionEvent ae) {
            File file = UIUtilities.saveFile(new RDVConfigurationFileFilter());
            if (file != null) {
                if (file.getName().indexOf(".") == -1) {
                    file = new File(file.getAbsolutePath() + ".rdv");
                }

                // prompt for overwrite if file already exists
                if (file.exists()) {
                    int overwriteReturn = JOptionPane.showConfirmDialog(null,
                            file.getName() + " already exists. Do you want to overwrite it?", "Overwrite file?",
                            JOptionPane.YES_NO_OPTION);
                    if (overwriteReturn == JOptionPane.NO_OPTION) {
                        return;
                    }
                }

                ConfigurationManager.saveConfiguration(file);
            }
        }
    };

    importAction = new DataViewerAction("Import", "Import Menu", KeyEvent.VK_I, "icons/import.gif");

    exportAction = new DataViewerAction("Export", "Export Menu", KeyEvent.VK_E, "icons/export.gif");

    exportVideoAction = new DataViewerAction("Export video channels",
            "Export video on the server to the local computer") {
        /** serialization version identifier */
        private static final long serialVersionUID = -6420430928972633313L;

        public void actionPerformed(ActionEvent ae) {
            showExportVideoDialog();
        }
    };

    exitAction = new DataViewerAction("Exit", "Exit RDV", KeyEvent.VK_X) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3137490972014710133L;

        public void actionPerformed(ActionEvent ae) {
            Application.getInstance().exit(ae);
        }
    };

    controlAction = new DataViewerAction("Control", "Control Menu", KeyEvent.VK_C);

    realTimeAction = new DataViewerAction("Real Time", "View data in real time", KeyEvent.VK_R,
            KeyStroke.getKeyStroke(KeyEvent.VK_R, menuShortcutKeyMask), "icons/rt.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -7564783609370910512L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.monitor();
        }
    };

    playAction = new DataViewerAction("Play", "Playback data", KeyEvent.VK_P,
            KeyStroke.getKeyStroke(KeyEvent.VK_P, menuShortcutKeyMask), "icons/play.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 5974457444931142938L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.play();
        }
    };

    pauseAction = new DataViewerAction("Pause", "Pause data display", KeyEvent.VK_A,
            KeyStroke.getKeyStroke(KeyEvent.VK_S, menuShortcutKeyMask), "icons/pause.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5297742186923194460L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.pause();
        }
    };

    beginningAction = new DataViewerAction("Go to beginning", "Move the location to the start of the data",
            KeyEvent.VK_B, KeyStroke.getKeyStroke(KeyEvent.VK_B, menuShortcutKeyMask), "icons/begin.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 9171304956895497898L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationBegin();
        }
    };

    endAction = new DataViewerAction("Go to end", "Move the location to the end of the data", KeyEvent.VK_E,
            KeyStroke.getKeyStroke(KeyEvent.VK_E, menuShortcutKeyMask), "icons/end.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 1798579248452726211L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationEnd();
        }
    };

    gotoTimeAction = new DataViewerAction("Go to time", "Move the location to specific date time of the data",
            KeyEvent.VK_T, KeyStroke.getKeyStroke(KeyEvent.VK_T, menuShortcutKeyMask)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6411442297488926326L;

        public void actionPerformed(ActionEvent ae) {
            TimeRange timeRange = RBNBHelper.getChannelsTimeRange();
            double time = DateTimeDialog.showDialog(frame, rbnb.getLocation(), timeRange.start, timeRange.end);
            if (time >= 0) {
                rbnb.setLocation(time);
            }
        }
    };

    updateChannelListAction = new DataViewerAction("Update Channel List", "Update the channel list",
            KeyEvent.VK_U, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), "icons/refresh.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -170096772973697277L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.updateMetadata();
        }
    };

    dropDataAction = new DataViewerAction("Drop Data", "Drop data if plaback can't keep up with data rate",
            KeyEvent.VK_D, "icons/drop_data.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7079791364881120134L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            rbnb.dropData(menuItem.isSelected());
        }
    };

    viewAction = new DataViewerAction("View", "View Menu", KeyEvent.VK_V);

    showChannelListAction = new DataViewerAction("Show Channels", "", KeyEvent.VK_L, "icons/channels.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 4982129759386009112L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            channelListPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showMetadataPanelAction = new DataViewerAction("Show Properties", "", KeyEvent.VK_P,
            "icons/properties.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 430106771704397810L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            metadataPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showControlPanelAction = new DataViewerAction("Show Control Panel", "", KeyEvent.VK_C,
            "icons/control.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6401715717710735485L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            controlPanel.setVisible(menuItem.isSelected());
        }
    };

    showAudioPlayerPanelAction = new DataViewerAction("Show Audio Player", "", KeyEvent.VK_A,
            "icons/audio.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4248275698973916287L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            audioPlayerPanel.setVisible(menuItem.isSelected());
        }
    };

    showMarkerPanelAction = new DataViewerAction("Show Marker Panel", "", KeyEvent.VK_M, "icons/info.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5253555511660929640L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            markerSubmitPanel.setVisible(menuItem.isSelected());
        }
    };

    dataPanelAction = new DataViewerAction("Arrange", "Arrange Data Panel Orientation", KeyEvent.VK_D);

    dataPanelHorizontalLayoutAction = new DataViewerAction("Horizontal Data Panel Orientation", "", -1,
            "icons/vertical.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 3356151813557187908L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.VERTICAL_LAYOUT);
        }
    };

    dataPanelVerticalLayoutAction = new DataViewerAction("Vertical Data Panel Orientation", "", -1,
            "icons/horizontal.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4629920180285927138L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.HORIZONTAL_LAYOUT);
        }
    };

    showHiddenChannelsAction = new DataViewerAction("Show Hidden Channels", "", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_H, menuShortcutKeyMask), "icons/hidden.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2723464261568074033L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            channelListPanel.showHiddenChannels(selected);
        }
    };

    hideEmptyTimeAction = new DataViewerAction("Hide time with no data", "", KeyEvent.VK_D) {
        /** serialization version identifier */
        private static final long serialVersionUID = -3123608144249355642L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            controlPanel.hideEmptyTime(selected);
        }
    };

    fullScreenAction = new DataViewerAction("Full Screen", "", KeyEvent.VK_F,
            KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6882310862616235602L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            if (menuItem.isSelected()) {
                if (enterFullScreenMode()) {
                    menuItem.setSelected(true);
                } else {
                    menuItem.setSelected(false);
                }
            } else {
                leaveFullScreenMode();
                menuItem.setSelected(false);
            }
        }
    };

    windowAction = new DataViewerAction("Window", "Window Menu", KeyEvent.VK_W);

    closeAllDataPanelsAction = new DataViewerAction("Close all data panels", "", KeyEvent.VK_C,
            "icons/closeall.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8104876009869238037L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
        }
    };

    helpAction = new DataViewerAction("Help", "Help Menu", KeyEvent.VK_H);

    usersGuideAction = new DataViewerAction("RDV Help", "Open the RDV User's Guide", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -2837190869008153291L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL usersGuideURL = new URL("http://it.nees.org/library/telepresence/rdv-19-users-guide.php");
                DataViewer.browse(usersGuideURL);
            } catch (Exception e) {
            }
        }
    };

    supportAction = new DataViewerAction("RDV Support", "Get support from NEESit", KeyEvent.VK_S) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6855670513381679226L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL supportURL = new URL("http://it.nees.org/support/");
                DataViewer.browse(supportURL);
            } catch (Exception e) {
            }
        }
    };

    releaseNotesAction = new DataViewerAction("Release Notes", "Open the RDV Release Notes", KeyEvent.VK_R) {
        /** serialization version identifier */
        private static final long serialVersionUID = 7223639998298692494L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL releaseNotesURL = new URL("http://it.nees.org/library/rdv/rdv-release-notes.php");
                DataViewer.browse(releaseNotesURL);
            } catch (Exception e) {
            }
        }
    };

    aboutAction = new DataViewerAction("About RDV", "", KeyEvent.VK_A) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3978467903181198979L;

        public void actionPerformed(ActionEvent ae) {
            showAboutDialog();
        }
    };

}

From source file:org.rdv.viz.image.HighResImageViz.java

public void buildPopupMenu(JPopupMenu menu, MouseEvent e) {
    super.buildPopupMenu(menu, e);

    ActionListener setTimerangeAction = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            double newScale = Double.parseDouble(ae.getActionCommand());
            setLocalTimescale(newScale);
        }/*from  w w w .  jav a  2 s  .c o  m*/
    };

    // regenerate new menu
    JMenu timeRangeMenu = new JMenu("Set Timerange");
    ButtonGroup timeRangeGroup = new ButtonGroup();
    JRadioButtonMenuItem range = new JRadioButtonMenuItem(TimeScale.TIME_SCALE_UNDEFINED_DESC);
    range.setActionCommand(String.valueOf(TimeScale.TIME_SCALE_UNDEFINED));
    range.addActionListener(setTimerangeAction);
    timeRangeGroup.add(range);
    timeRangeMenu.add(range);
    if (localTimeScale_ == TimeScale.TIME_SCALE_UNDEFINED)
        range.setSelected(true);

    Double timeScales[] = TimeScale.getGlobalTimeScales();
    for (int i = 0; i < timeScales.length; i++) {
        range = new JRadioButtonMenuItem(DataViewer.formatSeconds(timeScales[i]));
        range.setActionCommand(String.valueOf(timeScales[i]));
        range.addActionListener(setTimerangeAction);
        timeRangeGroup.add(range);
        timeRangeMenu.add(range);
        if (localTimeScale_ == timeScales[i])
            range.setSelected(true);
    }

    menu.add(timeRangeMenu);
    menu.addSeparator();

    // create a popup to copy an image to the clipboard
    final JMenuItem copyImageMenuItem = new JMenuItem("Copy");
    copyImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            copyImage();
        }
    });
    menu.add(copyImageMenuItem);
    menu.addSeparator();

    // create a popup to save an image
    final JMenuItem saveImageMenuItem = new JMenuItem("Save as...");
    saveImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            saveImage();
        }
    });
    menu.add(saveImageMenuItem);

    menu.addSeparator();

    // create a popup to copy an image to the clipboard
    final JMenuItem printImageMenuItem = new JMenuItem("Print...");
    printImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            printImage();
        }
    });
    menu.add(printImageMenuItem);

    menu.addSeparator();

    final JMenuItem zoomInMenuItem = new JMenuItem("Zoom in");
    zoomInMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            imagePanel.zoomIn();
        }
    });
    menu.add(zoomInMenuItem);

    final JMenuItem zoomOutMenuItem = new JMenuItem("Zoom out");
    zoomOutMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            imagePanel.zoomOut();
        }
    });
    menu.add(zoomOutMenuItem);

    final JSeparator zoomMenuSeparator = new JPopupMenu.Separator();
    menu.add(zoomMenuSeparator);

    final JCheckBoxMenuItem autoScaleMenuItem = new JCheckBoxMenuItem("Auto scale", imagePanel.isAutoScaling());
    autoScaleMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setAutoScale(autoScaleMenuItem.isSelected());
        }
    });
    menu.add(autoScaleMenuItem);

    final JMenuItem resetScaleMenuItem = new JMenuItem("Reset scale");
    resetScaleMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            imagePanel.setScale(1);
        }
    });
    menu.add(resetScaleMenuItem);

    final JCheckBoxMenuItem showNavigationImageMenuItem = new JCheckBoxMenuItem("Show navigation image",
            imagePanel.isNavigationImageEnabled());
    showNavigationImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setShowNavigationImage(showNavigationImageMenuItem.isSelected());
        }
    });
    menu.add(showNavigationImageMenuItem);

    //menu.addSeparator();

    final JCheckBoxMenuItem useThumbnailImageMenuItem = new JCheckBoxMenuItem("Use thumbnail image",
            useThumbnailImage);
    useThumbnailImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setUseThumbnailImage(useThumbnailImageMenuItem.isSelected());
        }
    });
    menu.add(useThumbnailImageMenuItem);

    boolean hasImage = displayedImageData != null;
    saveImageMenuItem.setEnabled(hasImage);
    copyImageMenuItem.setEnabled(hasImage);
    printImageMenuItem.setEnabled(hasImage);

    boolean enableZoom = hasImage;
    zoomInMenuItem.setEnabled(enableZoom);
    zoomInMenuItem.setVisible(true);
    zoomOutMenuItem.setEnabled(enableZoom);
    zoomOutMenuItem.setVisible(true);
    zoomMenuSeparator.setVisible(true);

    autoScaleMenuItem.setVisible(true);
    resetScaleMenuItem.setVisible(true);
    showNavigationImageMenuItem.setVisible(true);

    useThumbnailImageMenuItem.setSelected(useThumbnailImage);
    useThumbnailImageMenuItem.setVisible(imageHasThumbnail());

}