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(Action a) 

Source Link

Document

Creates a radio button menu item whose properties are taken from the Action supplied.

Usage

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

/** Creates new instance. */
public IndicatorPanel() {
    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
    initComponents();//from   ww w.  j av  a  2  s.  c  o  m
    this.jPanel7.add(Utils.getBusyJXLayer((AutoCompleteJComboBox) this.jComboBox1));

    editor = new DefaultDrawingEditor();
    editor.add(view);

    addCreationButtonsTo(creationToolbar, editor);

    JPopupButton pb = new JPopupButton();
    pb.setItemFont(UIManager.getFont("MenuItem.font"));
    labels.configureToolBarButton(pb, "actions");
    pb.add(new GroupAction(editor));
    pb.add(new UngroupAction(editor));
    pb.addSeparator();
    pb.add(new BringToFrontAction(editor));
    pb.add(new SendToBackAction(editor));
    pb.addSeparator();
    pb.add(new SelectAllAction());
    pb.add(new SelectSameAction(editor));
    pb.addSeparator();
    pb.add(new ToggleGridAction(editor));

    JMenu m = new JMenu(labels.getString("zoom"));
    JRadioButtonMenuItem rbmi;
    ButtonGroup group = new ButtonGroup();
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.1, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.75, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.0, null)));
    rbmi.setSelected(true);
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 2, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 3, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 4, null)));
    group.add(rbmi);
    pb.add(m);
    pb.setFocusable(false);
    creationToolbar.addSeparator();
    creationToolbar.add(pb);

    view.setDrawing(createDrawing());

    stockTask = null;

    initIndicatorProjectManager();
    initModuleProjectManager();
    // Must be done after project managers had been initialized.
    initListCellRenderer();
    createToolTipTextForJTabbedPane();
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jMenu8MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu8MenuSelected
    this.jMenu8.removeAll();
    final java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames();
    final String currentPortfolioName = this.getJStockOptions().getPortfolioName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String portfolioName : portfolioNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) jMenu8.add(new JRadioButtonMenuItem(portfolioName));
        buttonGroup.add(mi);//from   w  w w  .ja  v a 2  s .  c  o  m
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentPortfolioName)) {
                    JStock.this.selectActivePortfolio(s);
                }
            }

        });
        mi.setSelected(portfolioName.equals(currentPortfolioName));
    }

    jMenu8.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultiplePortolio..."),
            this.getImageIcon("/images/16x16/calc.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multiplePortfolios();
        }

    });
    jMenu8.add(mi);
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jMenu9MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu9MenuSelected
    this.jMenu9.removeAll();
    final java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames();
    final String currentWatchlistName = this.getJStockOptions().getWatchlistName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String watchlistName : watchlistNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) this.jMenu9.add(new JRadioButtonMenuItem(watchlistName));
        buttonGroup.add(mi);// w  w  w . j  av a2 s  .co m
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentWatchlistName)) {
                    JStock.this.selectActiveWatchlist(s);
                }
            }

        });
        mi.setSelected(watchlistName.equals(currentWatchlistName));
    }

    this.jMenu9.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultipleWatchlist..."),
            this.getImageIcon("/images/16x16/stock_timezone.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multipleWatchlists();
        }

    });
    this.jMenu9.add(mi);
}

From source file:org.yccheok.jstock.gui.JStock.java

public void createLookAndFeelMenuItems() {
    LookAndFeel currentlaf = UIManager.getLookAndFeel();

    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();

    for (int i = 0; i < lafInfo.length; i++) {
        JMenuItem mi = (JRadioButtonMenuItem) jMenu4.add(new JRadioButtonMenuItem(lafInfo[i].getName()));
        buttonGroup1.add(mi);//from   w  ww.j  a v  a  2  s.  c  om
        mi.addActionListener(new ChangeLookAndFeelAction(this, lafInfo[i].getClassName()));

        if (currentlaf != null) {
            if (lafInfo[i].getClassName().equals(currentlaf.getClass().getName())) {
                ((JRadioButtonMenuItem) mi).setSelected(true);
            }
        }
    }

    // Always on Top
    jMenu4.addSeparator();
    this.alwaysOnTopMenuItem = jMenu4.add(new JCheckBoxMenuItem(GUIBundle.getString("MainFrame_AlwaysOnTop")));

    this.alwaysOnTopMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            AbstractButton aButton = (AbstractButton) e.getSource();
            boolean selected = aButton.getModel().isSelected();

            JStock.this._setAlwaysOnTop(selected);
        }
    });
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void jMenu8MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu8MenuSelected
    this.jMenu8.removeAll();
    final java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames();
    final String currentPortfolioName = this.getJStockOptions().getPortfolioName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String portfolioName : portfolioNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) jMenu8.add(new JRadioButtonMenuItem(portfolioName));
        buttonGroup.add(mi);//from   www.j a v a  2  s .c  om
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentPortfolioName)) {
                    MainFrame.this.selectActivePortfolio(s);
                }
            }

        });
        mi.setSelected(portfolioName.equals(currentPortfolioName));
    }

    jMenu8.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultiplePortolio..."),
            this.getImageIcon("/images/16x16/calc.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multiplePortfolios();
        }

    });
    jMenu8.add(mi);
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void jMenu9MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu9MenuSelected
    this.jMenu9.removeAll();
    final java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames();
    final String currentWatchlistName = this.getJStockOptions().getWatchlistName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String watchlistName : watchlistNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) this.jMenu9.add(new JRadioButtonMenuItem(watchlistName));
        buttonGroup.add(mi);/* w  ww  .j a v  a2  s.  co  m*/
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentWatchlistName)) {
                    MainFrame.this.selectActiveWatchlist(s);
                }
            }

        });
        mi.setSelected(watchlistName.equals(currentWatchlistName));
    }

    this.jMenu9.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultipleWatchlist..."),
            this.getImageIcon("/images/16x16/stock_timezone.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multipleWatchlists();
        }

    });
    this.jMenu9.add(mi);
}

From source file:org.yccheok.jstock.gui.MainFrame.java

public void createLookAndFeelMenuItem() {
    LookAndFeel currentlaf = UIManager.getLookAndFeel();

    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();

    for (int i = 0; i < lafInfo.length; i++) {
        JMenuItem mi = (JRadioButtonMenuItem) jMenu4.add(new JRadioButtonMenuItem(lafInfo[i].getName()));
        buttonGroup1.add(mi);/*from  www  . j a  v a 2s .co  m*/
        mi.addActionListener(new ChangeLookAndFeelAction(this, lafInfo[i].getClassName()));

        if (currentlaf != null) {
            if (lafInfo[i].getClassName().equals(currentlaf.getClass().getName())) {
                ((JRadioButtonMenuItem) mi).setSelected(true);
            }
        }
    }
}

From source file:processing.app.Base.java

private JRadioButtonMenuItem createBoardMenusAndCustomMenus(final List<JMenu> boardsCustomMenus,
        List<JMenuItem> menuItemsToClickAfterStartup, Map<String, ButtonGroup> buttonGroupsMap,
        TargetBoard board, TargetPlatform targetPlatform, TargetPackage targetPackage) throws Exception {
    String selPackage = PreferencesData.get("target_package");
    String selPlatform = PreferencesData.get("target_platform");
    String selBoard = PreferencesData.get("board");

    String boardId = board.getId();
    String packageName = targetPackage.getId();
    String platformName = targetPlatform.getId();

    // Setup a menu item for the current board
    @SuppressWarnings("serial")
    Action action = new AbstractAction(board.getName()) {
        public void actionPerformed(ActionEvent actionevent) {
            BaseNoGui.selectBoard((TargetBoard) getValue("b"));
            filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard) getValue("b"), 1);

            onBoardOrPortChange();//  w w  w .  j av  a2s  .c  o m
            rebuildImportMenu(Editor.importMenu);
            rebuildExamplesMenu(Editor.examplesMenu);
        }
    };
    action.putValue("b", board);

    JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);

    if (selBoard.equals(boardId) && selPackage.equals(packageName) && selPlatform.equals(platformName)) {
        menuItemsToClickAfterStartup.add(item);
    }

    PreferencesMap customMenus = targetPlatform.getCustomMenus();
    for (final String menuId : customMenus.keySet()) {
        String title = customMenus.get(menuId);
        JMenu menu = getBoardCustomMenu(tr(title));

        if (board.hasMenu(menuId)) {
            PreferencesMap boardCustomMenu = board.getMenuLabels(menuId);
            for (String customMenuOption : boardCustomMenu.keySet()) {
                @SuppressWarnings("serial")
                Action subAction = new AbstractAction(tr(boardCustomMenu.get(customMenuOption))) {
                    public void actionPerformed(ActionEvent e) {
                        PreferencesData.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_"
                                + getValue("custom_menu_option"));
                        onBoardOrPortChange();
                    }
                };
                subAction.putValue("board", board);
                subAction.putValue("custom_menu_option", customMenuOption);

                if (!buttonGroupsMap.containsKey(menuId)) {
                    buttonGroupsMap.put(menuId, new ButtonGroup());
                }

                JRadioButtonMenuItem subItem = new JRadioButtonMenuItem(subAction);
                menu.add(subItem);
                buttonGroupsMap.get(menuId).add(subItem);

                String selectedCustomMenuEntry = PreferencesData.get("custom_" + menuId);
                if (selBoard.equals(boardId)
                        && (boardId + "_" + customMenuOption).equals(selectedCustomMenuEntry)) {
                    menuItemsToClickAfterStartup.add(subItem);
                }
            }
        }
    }

    return item;
}

From source file:processing.app.Base.java

public void rebuildProgrammerMenu() {
    programmerMenus = new LinkedList<>();

    ButtonGroup group = new ButtonGroup();
    for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
        for (TargetPlatform targetPlatform : targetPackage.platforms()) {
            for (String programmer : targetPlatform.getProgrammers().keySet()) {
                String id = targetPackage.getId() + ":" + programmer;

                @SuppressWarnings("serial")
                AbstractAction action = new AbstractAction(
                        targetPlatform.getProgrammer(programmer).get("name")) {
                    public void actionPerformed(ActionEvent actionevent) {
                        PreferencesData.set("programmer", "" + getValue("id"));
                    }/*from ww  w  .jav a 2s .c  o  m*/
                };
                action.putValue("id", id);
                JMenuItem item = new JRadioButtonMenuItem(action);
                if (PreferencesData.get("programmer").equals(id)) {
                    item.setSelected(true);
                }
                group.add(item);
                programmerMenus.add(item);
            }
        }
    }
}

From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java

public static void addExpansionMenu(JMenuBar menuBar) {

    ButtonGroup itemGroup = new ButtonGroup();

    // Create a menu
    JMenu menu = new JMenu("Expansion model");
    menuBar.add(menu);/*from w  w  w  . j a va  2  s .  c o  m*/

    // Create none item
    JMenuItem noneItem = new JRadioButtonMenuItem("None");
    noneItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("No expansion strategy selected.");
            expansionStrategy = null;
        }
    });
    itemGroup.add(noneItem);
    menu.add(noneItem);

    // Create spoke model item
    JMenuItem spokeItem = new JRadioButtonMenuItem("Spoke");
    spokeItem.setSelected(true);
    spokeItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Sets expansion statefy to Spoke.");
            expansionStrategy = new SpokeExpansion();
        }
    });
    itemGroup.add(spokeItem);
    menu.add(spokeItem);

    // Create an exit
    JMenuItem matrixItem = new JRadioButtonMenuItem("Matrix");
    matrixItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Sets expansion statefy to Matrix.");
            expansionStrategy = new MatrixExpansion();
        }
    });
    itemGroup.add(matrixItem);
    menu.add(matrixItem);
}