Example usage for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem

List of usage examples for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem

Introduction

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

Prototype

public JRadioButtonMenuItem() 

Source Link

Document

Creates a JRadioButtonMenuItem with no set text or icon.

Usage

From source file:RadioButtonSample.java

public static void main(String args[]) {

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton aButton = (AbstractButton) actionEvent.getSource();
            boolean selected = aButton.getModel().isSelected();
            System.out.println(actionEvent.getActionCommand() + " - selected? " + selected);
        }//from   www  .j a  va 2s  .c  o m
    };

    ItemListener itemListener = new ItemListener() {
        public void itemStateChanged(ItemEvent itemEvent) {
            AbstractButton aButton = (AbstractButton) itemEvent.getSource();
            int state = itemEvent.getStateChange();
            String selected = ((state == ItemEvent.SELECTED) ? "selected" : "not selected");
            System.out.println(aButton.getText() + " - selected? " + selected);
        }
    };

    JFrame frame = new JFrame("Radio Menu Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Menu");
    ButtonGroup buttonGroup = new ButtonGroup();
    menu.setMnemonic(KeyEvent.VK_M);

    JRadioButtonMenuItem emptyMenuItem = new JRadioButtonMenuItem();
    emptyMenuItem.setActionCommand("Empty");
    emptyMenuItem.addActionListener(actionListener);
    buttonGroup.add(emptyMenuItem);
    menu.add(emptyMenuItem);

    JRadioButtonMenuItem oneMenuItem = new JRadioButtonMenuItem("Partridge");
    oneMenuItem.addActionListener(actionListener);
    buttonGroup.add(oneMenuItem);
    menu.add(oneMenuItem);

    JRadioButtonMenuItem twoMenuItem = new JRadioButtonMenuItem("Turtle Doves", true);
    twoMenuItem.addActionListener(actionListener);
    buttonGroup.add(twoMenuItem);
    menu.add(twoMenuItem);

    JRadioButtonMenuItem threeMenuItem = new JRadioButtonMenuItem("French Hens", threeIcon);
    threeMenuItem.addItemListener(itemListener);
    buttonGroup.add(threeMenuItem);
    menu.add(threeMenuItem);

    JRadioButtonMenuItem fourMenuItem = new JRadioButtonMenuItem("Calling Birds", fourIcon, true);
    fourMenuItem.addActionListener(actionListener);
    buttonGroup.add(fourMenuItem);
    menu.add(fourMenuItem);

    JRadioButtonMenuItem fiveMenuItem = new JRadioButtonMenuItem(fiveIcon);
    fiveMenuItem.addActionListener(actionListener);
    fiveMenuItem.setActionCommand("Rings");
    buttonGroup.add(fiveMenuItem);
    menu.add(fiveMenuItem);

    JRadioButtonMenuItem sixMenuItem = new JRadioButtonMenuItem(sixIcon, true);
    sixMenuItem.addActionListener(actionListener);
    sixMenuItem.setActionCommand("Geese");
    buttonGroup.add(sixMenuItem);
    menu.add(sixMenuItem);

    menuBar.add(menu);
    frame.setJMenuBar(menuBar);
    frame.setSize(350, 250);
    frame.setVisible(true);
}

From source file:net.sf.firemox.AbstractMainForm.java

/**
 * Initialize the components of this form.
 */// w  ww . j a  v  a 2  s. co  m
protected void initAbstractMenu() {
    // "TBS" menu
    tbsMenu = UIHelper.buildMenu("menu_options_tbs");
    ButtonGroup group4 = new ButtonGroup();
    final MdbListener mdbListener = new MdbListener(this);
    final File[] mdbs = MToolKit.getFile(IdConst.TBS_DIR)
            .listFiles((FileFilter) FileFilterUtils.suffixFileFilter("xml"));
    String defaultTbs = MToolKit.tbsName;
    for (File mdb : mdbs) {
        String mdbName = FilenameUtils.getBaseName(mdb.getName());
        JRadioButtonMenuItem itemChck = new JRadioButtonMenuItem();
        MToolKit.tbsName = mdbName;
        updateMdbMenu(mdbName, itemChck);
        itemChck.setActionCommand(mdbName);
        itemChck.setFont(MToolKit.defaultFont);
        itemChck.addActionListener(mdbListener);
        group4.add(itemChck);
        tbsMenu.add(itemChck);
        if (mdbName.equals(defaultTbs)) {
            itemChck.setSelected(true);
        }
    }
    MToolKit.tbsName = defaultTbs;
    tbsMenu.add(new JSeparator());

    // "More TBS" menu item
    tbsMenu.add(UIHelper.buildMenu("menu_options_tbs_more", mdbListener));
    tbsMenu.add(new JSeparator());
    final JMenuItem updateMdbMenu = UIHelper.buildMenu("menu_options_tbs_update", mdbListener);
    updateMdbMenu.setEnabled(false);
    tbsMenu.add(updateMdbMenu);
    tbsMenu.add(UIHelper.buildMenu("menu_options_tbs_rebuild", mdbListener));
    optionMenu.add(new JSeparator());
    optionMenu.add(tbsMenu);
}

From source file:brainflow.app.toplevel.BrainFlow.java

private MenuFactory createMenuFactory() {
    return new MenuFactory() {
        @Override/*w  ww.ja va 2  s .c  om*/
        public JMenu createMenu() {
            return new JideMenu();
        }

        @Override
        public JMenuItem createMenuItem() {
            return new JMenuItem();
        }

        @Override
        public JCheckBoxMenuItem createCheckBoxMenuItem() {
            return new JCheckBoxMenuItem();
        }

        @Override
        public JRadioButtonMenuItem createRadioButtonMenuItem() {
            return new JRadioButtonMenuItem();
        }

        @Override
        public JPopupMenu createPopupMenu() {
            return new JPopupMenu();
        }

        @Override
        public JMenuBar createMenuBar() {
            return new CommandMenuBar();
        }
    };

}

From source file:lab4.YouQuiz.java

private void initComponents() {

    menuBar = new JMenuBar();
    menuBarFile = new JMenu();
    menuBarExit = new JMenuItem();
    menuBarMode = new JMenu();
    menuBarEdit = new JRadioButtonMenuItem();
    menuBarQuiz = new JRadioButtonMenuItem();
    menuBarHelp = new JMenu();
    menuBarAbout = new JMenuItem();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("YouQuiz | Your Quiz Factory");
    setIconImage((new ImageIcon(getClass().getClassLoader().getResource("resources/icon.png"))).getImage());
    setMinimumSize(new Dimension(800, 500));
    setResizable(false);//from  w w  w  .  j av  a  2s.co m

    menuBarFile.setText("File");

    menuBarExit.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
    menuBarExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    menuBarExit.setText("Exit");
    menuBarFile.add(menuBarExit);

    menuBar.add(menuBarFile);

    menuBarMode.setText("Mode");

    menuBarEdit.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
    menuBarEdit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //Execute when button is pressed
            System.out.println("You clicked the button");
        }
    });
    menuBarEdit.setText("Edit Mode");

    menuBarQuiz.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
    menuBarQuiz.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //Execute when button is pressed
            System.out.println("You clicked the button");
        }
    });
    menuBarQuiz.setSelected(true);
    menuBarQuiz.setText("Quiz Mode");

    ButtonGroup menuBarGroup = new ButtonGroup();
    menuBarGroup.add(menuBarEdit);
    menuBarGroup.add(menuBarQuiz);

    menuBarMode.add(menuBarEdit);
    menuBarMode.add(menuBarQuiz);

    menuBar.add(menuBarMode);

    menuBarHelp.setText("Help");

    menuBarAbout.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
    menuBarAbout.setText("About");
    menuBarAbout.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            JOptionPane.showMessageDialog(null, "By Anwar Mohamed ~ 2491", "YouQuiz",
                    JOptionPane.INFORMATION_MESSAGE,
                    new ImageIcon(getClass().getClassLoader().getResource("resources/icon-48.png")));
        }
    });
    menuBarHelp.add(menuBarAbout);

    menuBar.add(menuBarHelp);
    setJMenuBar(menuBar);

    pack();
    setLocationRelativeTo(null);
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

@Override
protected void displayPopupMenu(int x, int y) {
    LegendTitle legend = getChart().getLegend();
    if (legend != null) {
        boolean isVisable = legend.isVisible();
        RectangleEdge location = legend.getPosition();
        if (isVisable) {
            if (location.equals(RectangleEdge.BOTTOM)) {
                legendBottom.setSelected(true);
                legendNone.setSelected(false);
                legendInternal.setSelected(false);
                legendRight.setSelected(false);
            } else if (isVisable && location.equals(RectangleEdge.RIGHT)) {
                legendRight.setSelected(true);
                legendNone.setSelected(false);
                legendInternal.setSelected(false);
                legendBottom.setSelected(false);
            }//from  ww w .ja  v  a2s .  c  om
        } else {
            if (isInternalLegendEnabled) {
                legendNone.setSelected(false);
                legendInternal.setSelected(true);
                legendRight.setSelected(false);
                legendBottom.setSelected(false);
            } else {
                legendNone.setSelected(true);
                legendInternal.setSelected(false);
                legendRight.setSelected(false);
                legendBottom.setSelected(false);
            }
        }
    }
    XYDataset dataset = getChart().getXYPlot().getDataset();
    curveManagementMenu.removeAll();
    if (dataset.getSeriesCount() > 0) {
        curveManagementMenu.setEnabled(true);
        JMenuItem focusNoneCurveItem = new JRadioButtonMenuItem();
        focusNoneCurveItem.setText("None");
        focusNoneCurveItem.setActionCommand(UNFOCUS_CURVE_COMMAND);
        focusNoneCurveItem.addActionListener(this);
        curveManagementMenu.add(focusNoneCurveItem);
        boolean isCurveFocused = false;
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            String seriesKey = (String) dataset.getSeriesKey(i);
            JMenuItem focusOnCurveItem = new JRadioButtonMenuItem();
            focusOnCurveItem.setText(seriesKey);
            focusOnCurveItem.setActionCommand(FOCUS_ON_COMMAND + "-" + seriesKey);
            focusOnCurveItem.addActionListener(this);
            curveManagementMenu.add(focusOnCurveItem);
            if (i == selectedSeriesIndex) {
                focusOnCurveItem.setSelected(true);
                isCurveFocused = true;
            }
        }
        if (!isCurveFocused) {
            focusNoneCurveItem.setSelected(true);
        }
    } else {
        curveManagementMenu.setEnabled(false);
    }
    //        addMaskMenu(x, y);
    super.displayPopupMenu(x, y);
}

From source file:org.gumtree.vis.awt.JChartPanel.java

protected void addMaskMenu(int x, int y) {
    if (this.removeSelectedMaskMenuItem != null) {
        boolean isRemoveMenuEnabled = false;
        if (this.selectedMask != null) {
            Rectangle2D screenMask = ChartMaskingUtilities.getMaskFramework(selectedMask, getScreenDataArea(),
                    getChart());//from  w  w w  .  jav  a 2 s  . com
            if (screenMask.contains(x, y)) {
                isRemoveMenuEnabled = true;
            }
        }
        this.removeSelectedMaskMenuItem.setEnabled(isRemoveMenuEnabled);
        if (isRemoveMenuEnabled) {
            removeSelectedMaskMenuItem.setVisible(true);
            removeSelectedMaskMenuItem.setText("Remove " + selectedMask.getName());
        } else {
            //              removeSelectedMaskMenuItem.setText("Mask Management");
            removeSelectedMaskMenuItem.setVisible(false);
        }
    }
    maskManagementMenu.removeAll();
    if (maskList.size() > 0) {
        maskManagementMenu.setEnabled(true);
        JMenuItem selectNoneMaskItem = new JRadioButtonMenuItem();
        selectNoneMaskItem.setText("Select None");
        selectNoneMaskItem.setActionCommand(DESELECT_MASK_COMMAND);
        selectNoneMaskItem.addActionListener(this);
        maskManagementMenu.add(selectNoneMaskItem);
        boolean isInShade = false;
        for (AbstractMask mask : maskList.keySet()) {
            Rectangle2D screenMask = ChartMaskingUtilities.getMaskFramework(mask, getScreenDataArea(),
                    getChart());
            if (screenMask.contains(x, y)) {
                JMenuItem selectMaskItem = new JRadioButtonMenuItem();
                selectMaskItem.setText("Select " + mask.getName());
                selectMaskItem.setActionCommand(SELECT_MASK_COMMAND + "-" + mask.getName());
                if (mask == selectedMask) {
                    selectMaskItem.setSelected(true);
                }
                selectMaskItem.addActionListener(this);
                maskManagementMenu.add(selectMaskItem);
                isInShade = true;
            }
        }
        if (isInShade) {
            if (selectedMask == null) {
                selectNoneMaskItem.setSelected(true);
            }
        } else {
            for (AbstractMask mask : getMasks()) {
                JMenuItem selectMaskItem = new JRadioButtonMenuItem();
                selectMaskItem.setText("Select " + mask.getName());
                selectMaskItem.setActionCommand(SELECT_MASK_COMMAND + "-" + mask.getName());
                if (mask == selectedMask) {
                    selectMaskItem.setSelected(true);
                }
                selectMaskItem.addActionListener(this);
                maskManagementMenu.add(selectMaskItem);
            }
            selectNoneMaskItem.setSelected(selectedMask == null);
        }
    } else {
        maskManagementMenu.setEnabled(false);
    }
}

From source file:ffx.ui.MainMenu.java

private JRadioButtonMenuItem addBGMI(ButtonGroup buttonGroup, JMenu menu, String icon, String actionCommand,
        int mnemonic, int accelerator, final ActionListener actionListener) {

    final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem();

    Action a = new AbstractAction() {
        @Override/*  www.j a va 2 s .co  m*/
        public void actionPerformed(ActionEvent e) {
            /**
             * If the ActionEvent is from a ToolBar button, pass it through
             * the JRadioButtonMenuItem.
             */
            if (e.getSource() != menuItem) {
                menuItem.doClick();
                return;
            }
            actionListener.actionPerformed(e);
        }
    };
    this.configureAction(a, icon, actionCommand, mnemonic, accelerator);
    menuItem.setAction(a);
    buttonGroup.add(menuItem);
    menu.add(menuItem);
    return menuItem;
}

From source file:com.pingtel.sipviewer.SIPViewerFrame.java

protected void initMenu() {
    JMenu menu;//  w w w.  ja v  a 2  s . co  m
    JMenu submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;

    // Create the menu bar.
    JMenuBar menuBar = new JMenuBar();
    this.setJMenuBar(menuBar);

    // Build the File menu.
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(menu);

    // Add the load-file items to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icOpenFileAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setAction(new icImportSyslogAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_Y);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem();
    menuItem.setAction(new icSaveAsAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the reload item to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icReloadAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the quit item to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icQuitAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menu.add(menuItem);

    // Build the Options menu.
    menu = new JMenu("Options");
    menu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(menu);

    // Add the split/single screen mode to the options menu
    menuItem = new JMenuItem();
    menuItem.setAction(new icScreenModeAction());
    menuItem.setMnemonic(KeyEvent.VK_M);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the show all dialogs option to the options menu
    menuItem = new JMenuItem();
    menuItem.setAction(new icShowAllDialogsAction());
    menuItem.setMnemonic(KeyEvent.VK_D);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the Time Zone Selection Time submenu
    submenu = new JMenu("Time Zone Setting");
    submenu.setMnemonic(KeyEvent.VK_Z);

    ButtonGroup timeZoneGroup = new ButtonGroup();

    // Set Time Zone to Local Time Zone
    m_localTimeZone = new JRadioButtonMenuItem();
    m_localTimeZone.setAction(new icSetTimeToLocalZone());
    m_localTimeZone.setMnemonic(KeyEvent.VK_L);
    timeZoneGroup.add(m_localTimeZone);
    m_localTimeZone.setSelected(true);
    submenu.add(m_localTimeZone);

    // Set Time Zone to UTC Time Zone
    m_utcTimeZone = new JRadioButtonMenuItem();
    m_utcTimeZone.setAction(new icSetTimeToUTCZone());
    m_utcTimeZone.setMnemonic(KeyEvent.VK_U);
    timeZoneGroup.add(m_utcTimeZone);
    submenu.add(m_utcTimeZone);

    menu.add(submenu);

    // Add the show/hide time index column
    menuItem = new JMenuItem();
    menuItem.setAction(new icTimeVisibilityAction());
    menuItem.setMnemonic(KeyEvent.VK_V);
    menu.add(menuItem);

    // Add the Time Display Format submenu
    submenu = new JMenu("Time Display Format");
    submenu.setMnemonic(KeyEvent.VK_T);

    ButtonGroup group = new ButtonGroup();
    m_dateAndTimeFormat = new JRadioButtonMenuItem();
    m_dateAndTimeFormat.setAction(new icDateAndTimeAction());
    m_dateAndTimeFormat.setMnemonic(KeyEvent.VK_I);
    group.add(m_dateAndTimeFormat);
    submenu.add(m_dateAndTimeFormat);

    m_defaultTimeFormat = new JRadioButtonMenuItem();
    m_defaultTimeFormat.setAction(new icTimeOfDay());
    m_defaultTimeFormat.setMnemonic(KeyEvent.VK_E);
    m_defaultTimeFormat.setSelected(true);
    group.add(m_defaultTimeFormat);
    submenu.add(m_defaultTimeFormat);

    m_sincePreviousFormat = new JRadioButtonMenuItem();
    m_sincePreviousFormat.setAction(new icSincePrevious());
    m_sincePreviousFormat.setMnemonic(KeyEvent.VK_P);
    group.add(m_sincePreviousFormat);
    submenu.add(m_sincePreviousFormat);

    m_sinceBeginningFormat = new JRadioButtonMenuItem();
    m_sinceBeginningFormat.setAction(new icSinceBeginning());
    m_sinceBeginningFormat.setMnemonic(KeyEvent.VK_B);
    group.add(m_sinceBeginningFormat);
    submenu.add(m_sinceBeginningFormat);

    m_sinceKeyIndexFormat = new JRadioButtonMenuItem();
    m_sinceKeyIndexFormat.setAction(new icSinceKeyIndex());
    m_sinceKeyIndexFormat.setMnemonic(KeyEvent.VK_K);
    group.add(m_sinceKeyIndexFormat);
    submenu.add(m_sinceKeyIndexFormat);

    menu.add(submenu);

    // Build the Help menu.
    menu = new JMenu("Help");
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);

    // Add the items to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icAboutAction());
    menu.add(menuItem);
}

From source file:org.gumtree.vis.awt.time.TimePlotPanel.java

@Override
protected void displayPopupMenu(int x, int y) {
    LegendTitle legend = getChart().getLegend();
    if (legend != null) {
        boolean isVisable = legend.isVisible();
        RectangleEdge location = legend.getPosition();
        if (isVisable) {
            if (location.equals(RectangleEdge.BOTTOM)) {
                legendBottom.setSelected(true);
                legendNone.setSelected(false);
                legendRight.setSelected(false);
            } else if (isVisable && location.equals(RectangleEdge.RIGHT)) {
                legendRight.setSelected(true);
                legendNone.setSelected(false);
                legendBottom.setSelected(false);
            }//  w w w. j a v a  2s  . c om
        } else {
            legendNone.setSelected(true);
            legendRight.setSelected(false);
            legendBottom.setSelected(false);
        }
    }
    curveManagementMenu.removeAll();
    curveResetMenu.removeAll();
    if (getXYPlot().getDatasetCount() > 0) {
        curveManagementMenu.setEnabled(true);
        curveResetMenu.setEnabled(true);

        JMenuItem focusNoneCurveItem = new JRadioButtonMenuItem();
        focusNoneCurveItem.setText("None");
        focusNoneCurveItem.setActionCommand(UNFOCUS_CURVE_COMMAND);
        focusNoneCurveItem.addActionListener(this);
        curveManagementMenu.add(focusNoneCurveItem);

        JMenuItem resetAllCurveItem = new JMenuItem();
        resetAllCurveItem.setText("RESET ALL");
        resetAllCurveItem.setActionCommand(RESET_ALL_CURVE_COMMAND);
        resetAllCurveItem.addActionListener(this);
        curveResetMenu.add(resetAllCurveItem);

        boolean isCurveFocused = false;
        for (int j = 0; j < getXYPlot().getDatasetCount(); j++) {
            XYDataset dataset = getChart().getXYPlot().getDataset(j);
            if (dataset != null) {
                for (int i = 0; i < dataset.getSeriesCount(); i++) {
                    String seriesKey = (String) dataset.getSeriesKey(i);
                    JMenuItem focusOnCurveItem = new JRadioButtonMenuItem();
                    focusOnCurveItem.setText(seriesKey);
                    focusOnCurveItem.setActionCommand(FOCUS_ON_COMMAND + "-" + seriesKey);
                    focusOnCurveItem.addActionListener(this);
                    curveManagementMenu.add(focusOnCurveItem);
                    if (dataset == selectedDataset && i == selectedSeriesIndex) {
                        focusOnCurveItem.setSelected(true);
                        isCurveFocused = true;
                    }

                    JMenuItem resetCurveItem = new JMenuItem();
                    resetCurveItem.setText("Reset " + seriesKey);
                    resetCurveItem.setActionCommand(RESET_CURVE_COMMAND + "-" + seriesKey);
                    resetCurveItem.addActionListener(this);
                    curveResetMenu.add(resetCurveItem);

                }
            }
        }
        if (!isCurveFocused) {
            focusNoneCurveItem.setSelected(true);
        }
    } else {
        curveManagementMenu.setEnabled(false);
        curveResetMenu.setEnabled(false);
    }

    showMultiAxesMenuItem.setSelected(isShowMultiaxes());

    if (isPaused) {
        pauseMenuItem.setText("Paused");
    } else {
        pauseMenuItem.setText("Click to Pause");
    }
    pauseMenuItem.setSelected(isPaused);
    super.displayPopupMenu(x, y);
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

public JMenu getViewMenu() {
    if (viewMenu == null) {
        viewMenu = new JMenu(viewMenuLabelText);

        ButtonGroup viewButtonGroup = new ButtonGroup();

        for (int i = 0; i < VIEWTYPE_COUNT; i++) {
            JRadioButtonMenuItem mi = new JRadioButtonMenuItem();
            mi.setAction(new ViewTypeAction(i));
            viewButtonGroup.add(mi);/*from w w  w.  j  av  a2 s  .co m*/
            viewMenu.add(mi);
        }

        updateViewMenu();
    }

    return viewMenu;
}