当前位置: 首页>>代码示例>>Java>>正文


Java JRadioButtonMenuItem.addActionListener方法代码示例

本文整理汇总了Java中javax.swing.JRadioButtonMenuItem.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JRadioButtonMenuItem.addActionListener方法的具体用法?Java JRadioButtonMenuItem.addActionListener怎么用?Java JRadioButtonMenuItem.addActionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JRadioButtonMenuItem的用法示例。


在下文中一共展示了JRadioButtonMenuItem.addActionListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: maybeShowPopup

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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());
    }
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:19,代码来源:TopToolBar.java

示例8: getEditMenu

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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;
}
 
开发者ID:iig-uni-freiburg,项目名称:SWAT20,代码行数:23,代码来源:SwatMenuBar.java

示例9: addRadioItem

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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;
}
 
开发者ID:pushkarkp,项目名称:twidlit,代码行数:17,代码来源:PersistentMenuBar.java

示例10: createRadioButtonMenuItem

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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;
}
 
开发者ID:thred,项目名称:climate-tray,代码行数:18,代码来源:SwingUtils.java

示例11: getThemeMenu

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
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;
    }
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:22,代码来源:AbstractPModelerScene.java

示例12: 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;
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:30,代码来源:WabitSwingSessionContextImpl.java

示例13: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ChangePackageViewTypeAction.java

示例14: ZoomMenu

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
public ZoomMenu() {
  super();

  sep = new JPopupMenu.Separator();
  add(sep);

  bg = new ButtonGroup();

  other = new JRadioButtonMenuItem(
    Resources.getString("Zoomer.ZoomMenu.other")); //$NON-NLS-1$
  other.setActionCommand(OTHER);
  other.addActionListener(this);
  bg.add(other);
  add(other);

  addSeparator();

  final JMenuItem fw = new JMenuItem(
    Resources.getString("Zoomer.ZoomMenu.fit_width")); //$NON-NLS-1$
  fw.setActionCommand(FIT_WIDTH);
  fw.addActionListener(this);
  add(fw);

  final JMenuItem fh = new JMenuItem(
    Resources.getString("Zoomer.ZoomMenu.fit_height")); //$NON-NLS-1$
  fh.setActionCommand(FIT_HEIGHT);
  fh.addActionListener(this);
  add(fh);

  final JMenuItem fv = new JMenuItem(
    Resources.getString("Zoomer.ZoomMenu.fit_visible")); //$NON-NLS-1$
  fv.setActionCommand(FIT_VISIBLE);
  fv.addActionListener(this);
  add(fv);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:36,代码来源:Zoomer.java

示例15: init

import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
private void init() {
    JMenuItem addRowButton = Utils.createMenuItem("Add Row", ""
            + "Ctrl+Plus to add a row at last"
            + "<br>"
            + "Ctrl+I to insert a row before the selected row"
            + "<br>"
            + "Ctrl+R to replicate the row", Keystroke.ADD_ROWP, actionListener);
    add(addRowButton);
    add(Utils.createMenuItem("Delete Rows", "Ctrl+Minus", Keystroke.REMOVE_ROW, actionListener));
    addSeparator();

    add(Utils.createMenuItem("Toggle BreakPoint", "Ctrl+B", Keystroke.BREAKPOINT, actionListener));
    add(Utils.createMenuItem("Toggle Comment", "Ctrl+/", Keystroke.COMMENT, actionListener));

    addSeparator();
    add(Utils.createMenuItem("Cut", "Ctrl+X", Keystroke.CUT, actionListener));
    add(Utils.createMenuItem("Copy", "Ctrl+C", Keystroke.COPY, actionListener));
    add(Utils.createMenuItem("Paste", "Ctrl+V", Keystroke.PASTE, actionListener));
    addSeparator();
    add(Utils.createMenuItem("Create Reusable", actionListener));

    JMenu goToMenu = new JMenu("Go To");
    goToMenu.add(Utils.createMenuItem("Go To Reusable", actionListener));
    goToMenu.add(Utils.createMenuItem("Go To Object", actionListener));
    goToMenu.add(Utils.createMenuItem("Go To TestData", actionListener));
    add(goToMenu);
    add(Utils.createMenuItem("Paramterize", actionListener));
    addSeparator();

    JRadioButtonMenuItem toggleValidation = new JRadioButtonMenuItem("Toggle Validation", true);
    toggleValidation.addActionListener(actionListener);
    add(toggleValidation);
    addSeparator();

    add(saveMenuItem = Utils.createMenuItem("Save", "Ctrl+S", Keystroke.SAVE, actionListener));
    add(Utils.createMenuItem("Reload", "F5", Keystroke.F5, actionListener));
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:38,代码来源:TestCasePopupMenu.java


注:本文中的javax.swing.JRadioButtonMenuItem.addActionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。