本文整理汇总了Java中javax.swing.JRadioButtonMenuItem.setSelected方法的典型用法代码示例。如果您正苦于以下问题:Java JRadioButtonMenuItem.setSelected方法的具体用法?Java JRadioButtonMenuItem.setSelected怎么用?Java JRadioButtonMenuItem.setSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JRadioButtonMenuItem
的用法示例。
在下文中一共展示了JRadioButtonMenuItem.setSelected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
}
示例3: 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);
}
}
示例4: updateLookAndFeels
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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);
}
}
示例5: selectPartMenu
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
private void selectPartMenu(JMenuBar menubar) {
SbApp.trace("SbActionManager.selectPartMenu(" + menubar.getName() + ")");
//JMenu menu = menubar.getMenu(MENUBAR_INDEX_PARTS);
JMenu menu=mainMenu.menuParts;
Component[] comps = menu.getMenuComponents();
for (Component comp : comps) {
if (comp instanceof JRadioButtonMenuItem) {
JRadioButtonMenuItem rbmi = (JRadioButtonMenuItem) comp;
ChangePartAction action = (ChangePartAction) rbmi.getAction();
if (action.getPart().getId().equals(mainFrame.getCurrentPart().getId())) {
rbmi.setSelected(true);
return;
}
}
}
}
示例6: populateAudioQualityMenu
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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);
}
示例7: makeGradingMenu
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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;
}
示例8: makeMenuItem
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
/**
* 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;
}
示例9: createChoice
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
private JMenuItem createChoice(final JavaProjectSettings.PackageViewType type, String label) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem();
Mnemonics.setLocalizedText(item, label);
item.setSelected(JavaProjectSettings.getPackageViewType() == type);
item.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
JavaProjectSettings.setPackageViewType(type);
}
});
return item;
}
示例10: update
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
@Override
public void update(Subject o) {
for(JRadioButtonMenuItem layoutButton : layoutMap.keySet() ) {
if(layoutMap.get(layoutButton) == networkPanel.getCurrentLayout() ) {
layoutButton.setSelected(true);
}
}
}
示例11: update
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
@Override
public void update(Subject o) {
for (JRadioButtonMenuItem layoutButton : layoutMap.keySet()) {
if (layoutMap.get(layoutButton) == networkPanel.getCurrentLayout()) {
layoutButton.setSelected(true);
}
}
}
示例12: obtainMenuItem
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
protected final JRadioButtonMenuItem obtainMenuItem () {
JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem();
Mnemonics.setLocalizedText(menuItem, filterItem.getDisplayName());
menuItem.setAction(this);
menuItem.addHierarchyListener(new ParentChangeListener(menuItem));
menuItem.setSelected(filterItem.isSelected());
return menuItem;
}
示例13: setProjectView4DevOrUser
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
/**
* Configures the View for menue 'view' -> 'Developer' or 'End user'
*/
private void setProjectView4DevOrUser() {
JRadioButtonMenuItem viewDeveloper = Application.getMainWindow().viewDeveloper;
JRadioButtonMenuItem viewEndUser = Application.getMainWindow().viewEndUser;
if (this.count()==0) {
// --- Disable both MenuItems -----------------
viewDeveloper.setEnabled(false);
viewEndUser.setEnabled(false);
} else {
// --- Enable both MenuItems ------------------
viewDeveloper.setEnabled(true);
viewEndUser.setEnabled(true);
// --- select the right item in relation ------
// --- to the project ------
String viewConfigured = Application.getProjectFocused().getProjectView();
if (viewConfigured.equalsIgnoreCase(Project.VIEW_User)) {
viewDeveloper.setSelected(false);
viewEndUser.setSelected(true);
} else {
viewEndUser.setSelected(false);
viewDeveloper.setSelected(true);
}
Application.getProjectFocused().getProjectEditorWindow().setViewForDeveloperOrEndUser();
}
}
示例14: createViewLogLinesSubMenu
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
private void createViewLogLinesSubMenu(final MenuActionListener menuActionLisener,
final JMenu edit) {
final JMenu viewLogLines = new JMenu(menuLabels.getString("viewMaxLines"));
edit.add(viewLogLines);
final ButtonGroup logLinesGroup = new ButtonGroup();
for (final MenuActions maxLogLines : MenuActions.logLines()) {
final JRadioButtonMenuItem submenuItem = new JRadioButtonMenuItem("Maximum " //NOPMD
+ maxLogLines.getLines());
viewLogLines.add(submenuItem);
logLinesGroup.add(submenuItem);
submenuItem.setSelected(maxLogLines.getLines() == view.getMaxLogLines());
submenuItem.addActionListener(menuActionLisener);
submenuItem.setActionCommand(maxLogLines.name());
}
}
示例15: DeBroglieViewMenu
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
public DeBroglieViewMenu( HAModule module ) {
super( HAResources.getString( "menu.deBroglieView" ) );
setMnemonic( HAResources.getChar( "menu.deBroglieView.mnemonic", 'D' ) );
_module = module;
_radialDistanceMenuItem = new JRadioButtonMenuItem( HAResources.getString( "menu.deBroglieView.radialDistance" ) );
_height3DMenuItem = new JRadioButtonMenuItem( HAResources.getString( "menu.deBroglieView.height3D" ) );
_brightnessMenuItem = new JRadioButtonMenuItem( HAResources.getString( "menu.deBroglieView.brightness" ) );
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add( _radialDistanceMenuItem );
buttonGroup.add( _height3DMenuItem );
buttonGroup.add( _brightnessMenuItem );
add( _radialDistanceMenuItem );
add( _height3DMenuItem );
add( _brightnessMenuItem );
// Event handling
ActionListener listener = new ActionListener() {
public void actionPerformed( ActionEvent e ) {
handledeBroglieViewChange( e.getSource() );
}
};
_radialDistanceMenuItem.addActionListener( listener );
_height3DMenuItem.addActionListener( listener );
_brightnessMenuItem.addActionListener( listener );
// Default state
if ( HADefaults.DEBROGLIE_VIEW == DeBroglieView.BRIGHTNESS ) {
_brightnessMenuItem.setSelected( true );
}
else if ( HADefaults.DEBROGLIE_VIEW == DeBroglieView.RADIAL_DISTANCE ) {
_radialDistanceMenuItem.setSelected( true );
}
else if ( HADefaults.DEBROGLIE_VIEW == DeBroglieView.HEIGHT_3D ) {
_height3DMenuItem.setSelected( true );
}
}