本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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]);
}
}
示例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]);
}
}
示例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;
}
示例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);
}
}
示例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());
}