當前位置: 首頁>>代碼示例>>Java>>正文


Java JRadioButtonMenuItem類代碼示例

本文整理匯總了Java中javax.swing.JRadioButtonMenuItem的典型用法代碼示例。如果您正苦於以下問題:Java JRadioButtonMenuItem類的具體用法?Java JRadioButtonMenuItem怎麽用?Java JRadioButtonMenuItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JRadioButtonMenuItem類屬於javax.swing包,在下文中一共展示了JRadioButtonMenuItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIconLeft

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:DropTargetLayer.java

示例2: getPopupPresenter

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:DebuggingActionsProvider.java

示例3: getContextMenu

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
/** 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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:ToolbarPool.java

示例4: getBuilder

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ButtonBuilders.java

示例5: attachWorkspace

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
/** 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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:WorkspaceSwitchAction.java

示例6: addActions

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:22,代碼來源:CompositeMenuToggleButton.java

示例7: updatePerspectives

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:27,代碼來源:PerspectiveMenu.java

示例8: initZoomItems

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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);
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:17,代碼來源:Zoomer.java

示例9: MetalThemeMenu

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
@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);
        }
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:MetalThemeMenu.java

示例10: getTimerMenu

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:28,代碼來源:TimeEntry.java

示例11: populateTypeSubMenu

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
/**
 * @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]);
    }
}
 
開發者ID:StottlerHenkeAssociates,項目名稱:SimBionic,代碼行數:21,代碼來源:SB_LocalsTree.java

示例12: populateTypeSubMenu

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
/**
 * @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]);
    }
}
 
開發者ID:StottlerHenkeAssociates,項目名稱:SimBionic,代碼行數:28,代碼來源:SB_Catalog.java

示例13: addCheckboxMenuItem

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:21,代碼來源:SimplePopup.java

示例14: load

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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);
	}
}
 
開發者ID:BloodShura,項目名稱:MPSBot,代碼行數:27,代碼來源:JLanguageMenu.java

示例15: changeDebugLevel

import javax.swing.JRadioButtonMenuItem; //導入依賴的package包/類
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());
}
 
開發者ID:repeats,項目名稱:Repeat,代碼行數:17,代碼來源:MainBackEndHolder.java


注:本文中的javax.swing.JRadioButtonMenuItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。