Java 类javax.swing.JRadioButtonMenuItem 实例源码

项目:incubator-netbeans    文件:DropTargetLayer.java   
private static int getIconLeft(JMenuItem item) {
    if(Utilities.isWindows()) {
        if(isVista()) {
            return 1;
        }
        if(hasRadioOrCheckSibling(item)) {
            return 20;
        } else {
            return 20;
        }
    }

    if(isAqua()) {
        if(item instanceof JRadioButtonMenuItem) {
            return 11;
        }
        return 14;
    }

    //metal or other (hopefully) basic derived L&Fs
    if(isRadioOrCheck(item)) {
        return 20;
    }
    return 10;
}
项目:incubator-netbeans    文件:DebuggingActionsProvider.java   
public JMenuItem getPopupPresenter() {
    JMenu displayAsPopup = new JMenu();
    Mnemonics.setLocalizedText(displayAsPopup, NbBundle.getMessage(DebuggingActionsProvider.class, "CTL_Session_Popup_Language"));

    String [] languages = session.getSupportedLanguages();
    String currentLanguage = session.getCurrentLanguage();
    for (int i = 0; i < languages.length; i++) {
        final String language = languages[i];
        JRadioButtonMenuItem langItem = new JRadioButtonMenuItem(new AbstractAction(language) {
            public void actionPerformed(ActionEvent e) {
                session.setCurrentLanguage(language);
            }
        });
        if (currentLanguage.equals(language)) langItem.setSelected(true);
        displayAsPopup.add(langItem);
    }
    return displayAsPopup;
}
项目:incubator-netbeans    文件:ToolbarPool.java   
/** Updates items in popup menu and returns itself.
*/
public JPopupMenu getContextMenu () {
    removeAll ();

    // generate list of available toolbar panels
    ButtonGroup bg = new ButtonGroup ();
    String current = ToolbarPool.getDefault ().getConfiguration ();
    for( String name : ToolbarPool.getDefault().getConfigurationsNow() ) {
        JRadioButtonMenuItem mi = new JRadioButtonMenuItem (name, (name.compareTo (current) == 0));
        mi.addActionListener (this);
        bg.add (mi);
        this.add (mi);
    }

    return this;
}
项目:incubator-netbeans    文件:ButtonBuilders.java   
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
        return new JButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
        return new JCheckBoxBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
        return new JRadioButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
        return new JToggleButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
        return new JCheckBoxMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
        return new JRadioButtonMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
        return new JMenuBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
        return new JMenuBarBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
        return new JMenuItemBuilder(instance, heap);
    }
    return null;
}
项目:incubator-netbeans    文件:WorkspaceSwitchAction.java   
/** Initializes listeners atc to the given workspace */
void attachWorkspace(
    Workspace workspace, Workspace[] currentDeskRef, Hashtable workspace2Menu, Hashtable menu2Workspace,
    Hashtable workspace2Listener, JMenu menu
) {
    // bugfix #6116 - change from getName() to getDisplayName()
    JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem();
    Mnemonics.setLocalizedText(menuItem, workspace.getDisplayName());
    HelpCtx.setHelpIDString(menuItem, WorkspaceSwitchAction.class.getName());

    ActionListener listener = createActionListener(menuItem, currentDeskRef, menu2Workspace, workspace2Menu);
    menuItem.addActionListener(listener);
    menu2Workspace.put(listener, workspace);
    workspace2Listener.put(workspace, listener);
    workspace2Menu.put(workspace, menuItem);
    workspace.addPropertyChangeListener(createNameListener(menuItem));
    menu.add(menuItem);
}
项目:rapidminer    文件:CompositeMenuToggleButton.java   
/**
 * Adds the given {@link Action}s to the {@link #popupMenu}.
 *
 * @param actions
 *            the actions which should be added to the menu
 */
public void addActions(Action... actions) {
    for (Action action : actions) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);

        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updateSelectionStatus();
            }
        });
        popupMenuGroup.add(item);
        popupMenu.add(item);
    }
}
项目:rapidminer    文件:PerspectiveMenu.java   
private void updatePerspectives(List<Perspective> perspectives) {
    removeAll();
    perspectiveMap.clear();
    workspaceMenuGroup = new ButtonGroup();
    for (Perspective p : perspectives) {
        String name = p.getName();
        Action action = new WorkspaceAction(PerspectiveMenu.this.perspectiveController, p, name);
        if (p.isUserDefined()) {
            action.putValue(Action.ACTION_COMMAND_KEY, "perspective-" + name);
            action.putValue(Action.NAME, name);
            ImageIcon createIcon = SwingTools
                    .createIcon("16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.icon"));
            action.putValue(Action.LARGE_ICON_KEY, createIcon);
            action.putValue(Action.SMALL_ICON, createIcon);
            action.putValue(Action.SHORT_DESCRIPTION,
                    I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.tip", name));
        }
        JMenuItem menuItem = new JRadioButtonMenuItem(action);
        add(menuItem);
        perspectiveMap.put(p.getName(), menuItem);
        workspaceMenuGroup.add(menuItem);
    }
    if (perspectiveMap.containsKey(perspectiveName)) {
        perspectiveMap.get(perspectiveName).setSelected(true);
    }
}
项目:VASSAL-src    文件:Zoomer.java   
public void initZoomItems() {
  while (getComponent(0) != sep) remove(0);

  final List<Double> levels = state.getLevels();
  for (int i = 0; i < levels.size(); ++i) {
    final String zs = Long.toString(Math.round(levels.get(i)*100)) + "%"; //$NON-NLS-1$
    final JMenuItem item = new JRadioButtonMenuItem(zs);
    item.setActionCommand(Integer.toString(i));
    item.addActionListener(this);
    bg.add(item);
    insert(item, 0);
  }

  ((JRadioButtonMenuItem) getComponent(
    state.getLevelCount() - state.getLevel() - 1)).setSelected(true);
}
项目:OpenJSharp    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:jdk8u-jdk    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:openjdk-jdk10    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:scorekeeperfrontend    文件:TimeEntry.java   
/**
 * Get the menu used for this timer
 * @return a JMenu for use by the application
 */
public JMenu getTimerMenu()
{
    JMenu timerMenu = new JMenu("Timer");
    for (Mode m : Mode.values())
    {
        JRadioButtonMenuItem bm = new JRadioButtonMenuItem();
        bm.setActionCommand(m.name());
        bm.addActionListener(this);
        timerMenu.add(bm);
        modeGroup.add(bm);
        switch (m)
        {
            case OFF: bm.setText("Off"); break;
            case BASIC_SERIAL: bm.setText("FarmTek/RaceAmerica/JACircuits"); break;
            case BWTIMER_SERIAL: bm.setText("BWTimer Serial"); break;
            case BWTIMER_NETWORK: bm.setText("BWTimer Network"); break;
            case PROTIMER_NETWORK: bm.setText("ProTimer Network"); break;
        }
    }

    modeGroup.setSelected(Mode.OFF);
    return timerMenu;
}
项目:openjdk9    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:SimBionic    文件:SB_LocalsTree.java   
/**
 * @deprecated
 */
private void populateTypeSubMenu(){
    ButtonGroup group = new ButtonGroup();
    int length = SB_Variable.kTypeNames.length;
    _typeItems = new JRadioButtonMenuItem[length];
    for (int i = 0; i < length; ++i)
    {
        _typeItems[i] = new JRadioButtonMenuItem(SB_Variable.kTypeNames[i]);
        // @kp 1.25.2005 removed because this functionality isn't
        // implemented yet
        if (i==SB_Variable.kUser){
            continue;
        }
        _typeItems[i].addActionListener(this);
        group.add(_typeItems[i]);
        _typeSubmenu.add(_typeItems[i]);
    }
}
项目:SimBionic    文件:SB_Catalog.java   
/**
 * @deprecated
 */
private void populateTypeSubMenu(){
    ButtonGroup group = new ButtonGroup();
    int length = SB_Variable.kTypeNames.length;
    _typeItems = new JMenuItem[length];
    for (int i = 0; i < length; ++i)
    {
        if (i == SB_Variable.kUser)
        {
            // @kp 1.25.2005 removed because this functionality isn't
            // implemented yet
            _typeItems[i] = new JMenu("User Types");
            ((JMenu) _typeItems[i]).add("type 1");
            ((JMenu) _typeItems[i]).add("type 2");
            ((JMenu) _typeItems[i]).add("type 3");
            continue;
        } else
        {
            _typeItems[i] = new JRadioButtonMenuItem(SB_Variable.kTypeNames[i]);
            _typeItems[i].addActionListener(this);
            group.add(_typeItems[i]);
        }
        _typeSubmenu.add(_typeItems[i]);
    }
}
项目:PhET    文件:SimplePopup.java   
JMenuItem addCheckboxMenuItem(Object menu, String entry, String basename,
                           String id, boolean state, boolean isRadio) {
  JMenuItem jm;
  if (isRadio) {
    JRadioButtonMenuItem jr = new JRadioButtonMenuItem(entry);
    jm = jr;
    jr.setArmed(state);
  } else {
    JCheckBoxMenuItem jcmi = new JCheckBoxMenuItem(entry);
    jm = jcmi;
    jcmi.setState(state);
  }
  jm.setSelected(state);
  jm.addItemListener(cmil);
  jm.setActionCommand(basename);
  updateButton(jm, entry, basename);
  jm.setName(id == null ? ((Component) menu).getName() + "." : id);
  addToMenu(menu, jm);
  return jm;
}
项目:MPSBot    文件:JLanguageMenu.java   
public void load() {
    ButtonGroup group = new ButtonGroup();

    removeAll();

    for (TranslationUnit unit : I18n.registeredUnits()) {
        Language language = unit.getLanguage();
        String text = language.getName();
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(text);

        group.add(item);
        item.addActionListener(event -> {
            item.setSelected(true);
            unitSelected(unit);
        });

        if (unit == I18n.currentUnit()) {
            item.setSelected(true);
        }

        CountryFlagRetrieveThread thread = new CountryFlagRetrieveThread(language, image -> EventQueue.invokeLater(() -> item.setIcon(new ImageIcon(image))));

        thread.start();
        add(item);
    }
}
项目:Repeat    文件:MainBackEndHolder.java   
protected void changeDebugLevel() {
    Level debugLevel = Level.WARNING;
    final JRadioButtonMenuItem[] buttons = {main.rbmiDebugSevere, main.rbmiDebugWarning, main.rbmiDebugInfo, main.rbmiDebugFine};

    for (int i = 0; i < DEBUG_LEVELS.length; i++) {
        if (buttons[i].isSelected()) {
            debugLevel = DEBUG_LEVELS[i];
            break;
        }
    }
    config.setNativeHookDebugLevel(debugLevel);

    // Get the logger for "org.jnativehook" and set the level to appropriate level.
    Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
    logger.setLevel(config.getNativeHookDebugLevel());
}
项目:jdk8u_jdk    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:JHelioviewer-SWHV    文件:TopToolBar.java   
private void maybeShowPopup(MouseEvent me) {
    if (me.isPopupTrigger() || me.getButton() == MouseEvent.BUTTON3) {
        JPopupMenu popUpMenu = new JPopupMenu();
        ButtonGroup group = new ButtonGroup();

        JRadioButtonMenuItem iconAndText = new JRadioButtonMenuItem("Icon and Text", displayMode == DisplayMode.ICONANDTEXT);
        iconAndText.addActionListener(e -> setDisplayMode(DisplayMode.ICONANDTEXT));
        group.add(iconAndText);
        popUpMenu.add(iconAndText);

        JRadioButtonMenuItem iconOnly = new JRadioButtonMenuItem("Icon Only", displayMode == DisplayMode.ICONONLY);
        iconOnly.addActionListener(e -> setDisplayMode(DisplayMode.ICONONLY));
        group.add(iconOnly);
        popUpMenu.add(iconOnly);

        popUpMenu.show(me.getComponent(), me.getX(), me.getY());
    }
}
项目:taxonaut    文件:LookAndFeelMenuItem.java   
protected void updateLookAndFeels()
   {
clearButtons();
LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel();
String current = currentLookAndFeel == null ? "" : currentLookAndFeel.getName();
LookAndFeelInfo[] infoArray = UIManager.getInstalledLookAndFeels();
if (infoArray == null || infoArray.length == 0) {
    return;
}

for (LookAndFeelInfo info : infoArray) {
    JRadioButtonMenuItem button = new JRadioButtonMenuItem(info.getName());
    button.setActionCommand(info.getClassName());
    if (info.getName().equals(current))
    button.setSelected(true);
    addButton(button);
}
   }
项目:lookaside_java-1.8.0-openjdk    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:TuxGuitar-1.3.1-fork    文件:SelectTrackAction.java   
protected void processAction(TGActionContext context) {
    final AWTEvent awtEvent = context.getAttribute(AWTEvent.class.getName());

    final Caret caret = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret();
    final JButton button = (JButton) awtEvent.getSource();
    final JPopupMenu menu = new JPopupMenu();
    Iterator<?> it = TuxGuitar.instance().getTablatureEditor().getTablature().getSong().getTracks();
    while( it.hasNext() ){
        final TGTrack track = (TGTrack) it.next();
        JMenuItem item = new JRadioButtonMenuItem( track.getName() , (track.getNumber() == caret.getTrack().getNumber()) );
        item.setFont( TGConfig.FONT_WIDGETS );
        item.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                caret.update( track.getNumber() );
                TuxGuitar.instance().updateCache( true );
            }
        });
        menu.add( item );
    }
    menu.show(button, 0, button.getHeight() );
}
项目:GitDirStat    文件:TreeObjectsTreeComponent.java   
private RadioButtonGroupModel createSortOrderMenuEntries(JMenu parent) {
    RadioButtonGroupModel sortOrderButtonGroupModel = new RadioButtonGroupModel();

    JRadioButtonMenuItem sortOrderAscSizeButton = new JRadioButtonMenuItem(
            "ascending");
    JRadioButtonMenuItem sortOrderDescSizeButton = new JRadioButtonMenuItem(
            "descending");

    sortOrderButtonGroupModel.add(sortOrderAscSizeButton, SortOrder.ASC);
    sortOrderButtonGroupModel.add(sortOrderDescSizeButton, SortOrder.DESC);
    sortOrderButtonGroupModel.setSelected(sortOrderDescSizeButton, true);

    parent.add(sortOrderAscSizeButton);
    parent.add(sortOrderDescSizeButton);

    return sortOrderButtonGroupModel;
}
项目:GitDirStat    文件:TreeObjectsTreeComponent.java   
private RadioButtonGroupModel createSortByMenuEntries(JMenu parent) {
    JRadioButtonMenuItem sortBySizeButton = new JRadioButtonMenuItem(
            "by size");
    JRadioButtonMenuItem sortByPathnameButton = new JRadioButtonMenuItem(
            "by pathname");

    RadioButtonGroupModel sortByButtonGroupModel = new RadioButtonGroupModel();
    sortByButtonGroupModel.add(sortBySizeButton, TreeObjectSortBy.SIZE);
    sortByButtonGroupModel.add(sortByPathnameButton, TreeObjectSortBy.NAME);
    sortByButtonGroupModel.setSelected(sortBySizeButton, true);

    parent.add(sortBySizeButton);
    parent.add(sortByPathnameButton);

    return sortByButtonGroupModel;
}
项目:rapidminer-studio    文件:CompositeMenuToggleButton.java   
/**
 * Adds the given {@link Action}s to the {@link #popupMenu}.
 *
 * @param actions
 *            the actions which should be added to the menu
 */
public void addActions(Action... actions) {
    for (Action action : actions) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);

        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updateSelectionStatus();
            }
        });
        popupMenuGroup.add(item);
        popupMenu.add(item);
    }
}
项目:rapidminer-studio    文件:PerspectiveMenu.java   
private void updatePerspectives(List<Perspective> perspectives) {
    removeAll();
    perspectiveMap.clear();
    workspaceMenuGroup = new ButtonGroup();
    for (Perspective p : perspectives) {
        String name = p.getName();
        Action action = new WorkspaceAction(PerspectiveMenu.this.perspectiveController, p, name);
        if (p.isUserDefined()) {
            action.putValue(Action.ACTION_COMMAND_KEY, "perspective-" + name);
            action.putValue(Action.NAME, name);
            ImageIcon createIcon = SwingTools
                    .createIcon("16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.icon"));
            action.putValue(Action.LARGE_ICON_KEY, createIcon);
            action.putValue(Action.SMALL_ICON, createIcon);
            action.putValue(Action.SHORT_DESCRIPTION,
                    I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.tip", name));
        }
        JMenuItem menuItem = new JRadioButtonMenuItem(action);
        add(menuItem);
        perspectiveMap.put(p.getName(), menuItem);
        workspaceMenuGroup.add(menuItem);
    }
    if (perspectiveMap.containsKey(perspectiveName)) {
        perspectiveMap.get(perspectiveName).setSelected(true);
    }
}
项目:SWAT20    文件:SwatMenuBar.java   
private JMenu getEditMenu() {
    JMenu editMenu = new JMenu("Edit");

    editModeButton = new JRadioButtonMenuItem("Edit Mode");
    editModeButton.setActionCommand(ACTION_COMMAND_EDIT_MODE);
    editModeButton.addActionListener(this);
    editModeButton.setAccelerator(KeyStroke.getKeyStroke('E', altKey));
    editMenu.add(editModeButton);


    analysisModeButton = new JRadioButtonMenuItem("Analyse Mode");
    analysisModeButton.setActionCommand(ACTION_COMMAND_ANALYSIS_MODE);
    analysisModeButton.addActionListener(this);
    analysisModeButton.setAccelerator(KeyStroke.getKeyStroke('A', altKey));
    editMenu.add(analysisModeButton);

    ButtonGroup editOrAnalyseGroup = new ButtonGroup();
    editOrAnalyseGroup.add(editModeButton);
    editOrAnalyseGroup.add(analysisModeButton);

    return editMenu;
}
项目:twidlit    文件:PersistentMenuBar.java   
public static void persist(JMenu menu, String tag) {
   int rb = 0;
   boolean inRb = false;
   for (int j = 0; j < menu.getItemCount(); ++j) {
      if (menu.getItem(j) instanceof JRadioButtonMenuItem) {
         if (!inRb) {
            inRb = true;
            ++rb;
         }
         JRadioButtonMenuItem rbItem = (JRadioButtonMenuItem)menu.getItem(j);
         if (rbItem.isSelected()) {
            Persist.set("#." + tag + menu.getText() + "." + rb, Persist.toTag("#." + rb + "." + rbItem.getActionCommand()));
         }
      } else {
         inRb = false;
         if (menu.getItem(j) instanceof JCheckBoxMenuItem) {
            JCheckBoxMenuItem cbItem = (JCheckBoxMenuItem)menu.getItem(j);
            Persist.set("#." + tag + menu.getText() + ' ' + cbItem.getText(), cbItem.getState() ? "true" : "false");
         } else
         if (menu.getItem(j) instanceof JMenu) {
            persist((JMenu)menu.getItem(j), tag);
         }
      }
   }
}
项目:twidlit    文件:PersistentMenuBar.java   
protected JRadioButtonMenuItem addRadioItem(JMenu menu, String text, ButtonGroup buttonGroup) {
   boolean selected = false;
   for (int i = 1; !selected; ++i) {
      String selection = Persist.get("#." + menu.getText() + "." + i);
      if (selection == null) {
         break;
      }
      selected = Persist.match("#." + selection, "#." + i + "." + text);
   }
   JRadioButtonMenuItem item = new JRadioButtonMenuItem(text, selected);
   menu.add(item);
   item.setActionCommand(text);
   item.addActionListener(this);
   buttonGroup.add(item);
   return item;
}
项目:TOTP-Generator    文件:MainUI.java   
public boolean selectView(String view){
    if(view.equals("*")){
        rdbtSAll.setSelected(true);
        return true;
    }
    else if(view.equals("#")){
        rdbtSStd.setSelected(true);
        return true;
    }
    else if(view.equals("~")){
        rdbtnNTag.setSelected(true);
        return true;
    }
    else{
        int size = mnShow.getItemCount();
        for(int i=3;i<size;i++){
            if(!(mnShow.getItem(i) instanceof JRadioButtonMenuItem)) continue;
            if(!((JRadioButtonMenuItem)mnShow.getItem(i)).getText().equals(view)) continue;
            ((JRadioButtonMenuItem)mnShow.getItem(i)).setSelected(true);
            return true;
        }
    }
    return false;
}
项目:LoboBrowser    文件:ComponentSource.java   
private void populateSearchers() {
  final JMenu searchersMenu = this.searchersMenu;
  searchersMenu.removeAll();
  final ToolsSettings settings = ToolsSettings.getInstance();
  final Collection<SearchEngine> searchEngines = settings.getSearchEngines();
  final SearchEngine selectedEngine = settings.getSelectedSearchEngine();
  if (searchEngines != null) {
    for (final SearchEngine se : searchEngines) {
      final SearchEngine finalSe = se;
      final JRadioButtonMenuItem item = new JRadioButtonMenuItem();
      item.setAction(new AbstractAction() {
        private static final long serialVersionUID = -3263394523150719487L;

        public void actionPerformed(final ActionEvent e) {
          settings.setSelectedSearchEngine(finalSe);
          settings.save();
          ComponentSource.this.updateSearchButtonTooltip();
        }
      });
      item.setSelected(se == selectedEngine);
      item.setText(se.getName());
      item.setToolTipText(se.getDescription());
      searchersMenu.add(item);
    }
  }
}
项目:climate-tray    文件:SwingUtils.java   
public static JRadioButtonMenuItem createRadioButtonMenuItem(String text, Icon icon, String toolTip,
    ActionListener... listeners)
{
    JRadioButtonMenuItem result = new JRadioButtonMenuItem(text, icon);

    if (toolTip != null)
    {
        result.setToolTipText(toolTip);
    }

    for (ActionListener listener : listeners)
    {
        result.addActionListener(listener);
    }

    return result;
}
项目:NBModeler    文件:AbstractPModelerScene.java   
protected JMenu getThemeMenu() {
        JMenu themeMenu = new JMenu("Theme");
        ButtonGroup thmemeGroup = new javax.swing.ButtonGroup();

        for (final Entry<String, Class<? extends IColorScheme>> scheme : this.getColorSchemes().entrySet()) {
            JRadioButtonMenuItem schemeMenu = new JRadioButtonMenuItem(scheme.getKey());
            schemeMenu.addActionListener((ActionEvent e) -> {
                NbPreferences.forModule(AbstractPModelerScene.this.getClass())
                        .put("theme", scheme.getValue().getSimpleName());
                AbstractPModelerScene.this.setColorScheme(scheme.getValue());
                reinstallColorScheme();
                AbstractPModelerScene.this.getModelerPanelTopComponent().changePersistenceState(false);
            });
            themeMenu.add(schemeMenu);
            thmemeGroup.add(schemeMenu);
//            if (this.getColorScheme().getId().equals(scheme.getId())) {
//                schemeMenu.setSelected(true);
//            }
        }
        return themeMenu;
    }
项目:vizardous    文件:MyPopUpMenu.java   
private void setVisualizationMode(final VisualizationViewer panel, JRadioButtonMenuItem pickingMode,JRadioButtonMenuItem tranformingMode) {
//        pickingMode.addActionListener(new ActionListener() {
//
//            @Override
//            public void actionPerformed(ActionEvent ae) {
//                DefaultModalGraphMouse gm = new DefaultModalGraphMouse<Cell, Clade>();
//                gm.setMode(ModalGraphMouse.Mode.PICKING);
//                panel.setGraphMouse(gm);
//                panel.repaint();
//                System.out.println("PICKING mouse mode");
//            }
//        });
//
//        tranformingMode.addActionListener(new ActionListener() {
//
//            @Override
//            public void actionPerformed(ActionEvent ae) {
//                DefaultModalGraphMouse gm = new DefaultModalGraphMouse<Cell, Clade>();
//                gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
//                panel.setGraphMouse(gm);
//                System.out.println("TRANSFORMING mouse mode");
//                panel.repaint();
//            }
//        });
    }
项目:openwonderland    文件:AudioMenu.java   
private void populateAudioQualityMenu() {
    ButtonGroup audioQualityButtons = new ButtonGroup();

    for (AudioQuality quality : AudioQuality.values()) {
        final AudioQuality fq = quality;
        JRadioButtonMenuItem mitem = new JRadioButtonMenuItem(
                new AbstractAction(quality.toString()) {

                    public void actionPerformed(ActionEvent arg0) {
                        setAudioQuality(fq);
                    }
                });

        audioQualityMenu.add(mitem);
        audioQualityButtons.add(mitem);

        SoftphoneControlImpl softphoneControlImpl =
                SoftphoneControlImpl.getInstance();

        if (quality.equals(softphoneControlImpl.getAudioQuality())) {
            mitem.setSelected(true);
        }
    }

    audioQualityMenu.setEnabled(true);
}
项目:Shuffle-Move    文件:ShuffleMenuBar.java   
private JMenu makeGradingMenu() {
   JMenu menu = new JMenu(getString(KEY_GRADING_MENU));
   buttonToi18nKeyMap.put(menu, () -> getString(KEY_GRADING_MENU));
   GradingMode selectedMode = getUser().getCurrentGradingMode();
   ButtonGroup group = new ButtonGroup();
   modeMap = new HashMap<GradingMode, AbstractButton>();
   for (GradingMode mode : getUser().getGradingModeManager().getGradingModeValues()) {
      String text = mode.geti18nString();
      JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(new AbstractAction(text) {
         @Override
         public void actionPerformed(ActionEvent e) {
            getUser().setGradingMode(mode);
         }
      });
      if (mode.equals(selectedMode)) {
         menuItem.setSelected(true);
      }
      group.add(menuItem);
      menu.add(menuItem);
      modeMap.put(mode, menuItem);
      buttonToi18nKeyMap.put(menuItem, () -> mode.geti18nString());
   }
   return menu;
}
项目:wabit    文件:WabitSwingSessionContextImpl.java   
/**
 * Creates a JMenuItem for this source list style. When the menu item is
 * activated, it applies the appropriate style to the given context.
 * 
 * @param context
 *            The session context the menu item belongs to (and operates
 *            upon).
 * @param sourceListStyleGroup
 *            The button group to add the menu item to (for mutual
 *            exclusion).
 * @return
 */
public JMenuItem makeMenuItem(
        final WabitSwingSessionContextImpl context,
        ButtonGroup sourceListStyleGroup) {
    JRadioButtonMenuItem mi =
        new JRadioButtonMenuItem(getLocalizedName() + " Source List");
    sourceListStyleGroup.add(mi);
    if (context.sourceListStyle == this) {
        // doing this before adding the action listener seems wise
        mi.setSelected(true);
    }
    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            apply(context, context.currentEditorPanel);
        }
    });
    return mi;
}
项目:infobip-open-jdk-8    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:jdk8u-dev-jdk    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}