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


Java JMenuItem.setActionCommand方法代码示例

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


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

示例1: addToRecent

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void addToRecent(String s) {

        for (int i = 0; i < iMaxRecent; i++) {
            if (s.equals(sRecent[i])) {
                return;
            }
        }

        if (sRecent[iRecent] != null) {
            mRecent.remove(iRecent);
        }

        sRecent[iRecent] = s;

        if (s.length() > 43) {
            s = s.substring(0, 40) + "...";
        }

        JMenuItem item = new JMenuItem(s);

        item.setActionCommand("#" + iRecent);
        item.addActionListener(this);
        mRecent.insert(item, iRecent);

        iRecent = (iRecent + 1) % iMaxRecent;
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:DatabaseManagerSwing.java

示例2: getPopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public JPopupMenu getPopupMenu() {
	JPopupMenu menu = new JPopupMenu();

	// add server items
	for (String serverName : remoteControllers.keySet()) {

		ConfigurableController controller = remoteControllers.get(serverName);

		// if the connection to the server is established
		if (controller.getModel().getSource().isConnected()) {
			if (!controller.getModel().hasAdminRights()) {

				JMenuItem newItem = new JMenuItem(I18N.getGUILabel("configurable_dialog.login_as_admin.small.item",
						serverName));
				newItem.setActionCommand(serverName);
				newItem.addActionListener(actionListener);
				menu.add(newItem);
			}
		}
	}
	return menu;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:LoginAsAdminDropDownButton.java

示例3: loadMyPalettes

import javax.swing.JMenuItem; //导入方法依赖的package包/类
protected void loadMyPalettes() {
	if(root==null)return;
	File dir = new File(root, "lut");
	if( !dir.exists())return;
	File[] files = dir.listFiles(new java.io.FileFilter() {
		public boolean accept(File file) {
			return file.getName().endsWith(".lut");
		}
	});
	for( int k=0 ; k<files.length ; k++) {
		try {
			Palette p = new Palette(files[k]);
			JMenuItem item = paletteMenu.add(new JMenuItem(
				p.toString(), p.getIcon()));
			item.setActionCommand("Loaded Palette");
			item.addActionListener(palListener);
			palettes.put( p.toString(), p);
		} catch(Exception ex) {
		}
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:22,代码来源:RenderingTools.java

示例4: initZoomItems

import javax.swing.JMenuItem; //导入方法依赖的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

示例5: makeProductionItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private JMenuItem makeProductionItem(GoodsType type, WorkLocation wl,
                                     int amount, UnitLabel unitLabel,
                                     boolean claim) {
    StringTemplate t = StringTemplate.template(type.getId() + ".workAs")
        .addAmount("%amount%", amount);
    if (claim) {
        t.addStringTemplate("%claim%", wl.getClaimTemplate());
    } else if (FreeColDebugger.isInDebugMode(FreeColDebugger.DebugMode.MENUS)) {
        t.addStringTemplate("%claim%", wl.getLocationLabel());
    } else {
        t.addName("%claim%", "");
    }
    JMenuItem menuItem = Utility.localizedMenuItem(t,
        new ImageIcon(gui.getImageLibrary().getSmallIconImage(type)));
    menuItem.setActionCommand(getWorkLabel(wl)
        + "/" + wl.getId() + "/" + type.getId()
        + "/" + ((claim) ? "!" : ""));
    menuItem.addActionListener(unitLabel);
    return menuItem;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:21,代码来源:QuickActionMenu.java

示例6: create

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private JMenuItem create(String name, KeyStroke keyStroke) {
    JMenuItem menuItem = new JMenuItem(name);
    menuItem.setActionCommand(name);
    menuItem.setAccelerator(keyStroke);
    menuItem.addActionListener(TestSetTree.this);
    return menuItem;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:8,代码来源:TestSetTree.java

示例7: init

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void init() {
    addNew = new JMenuItem("Add New");
    addNew.setActionCommand("Add New Enivronment");

    addNew.setIcon(Canvas.EmptyIcon);

    close = new JMenuItem("Close");
    close.setActionCommand("Close Enivronment");
    delete = new JMenuItem("Delete");
    delete.setActionCommand("Delete Enivronment");

    reopen = new JMenuItem("Reopen Closed");
    reopen.setActionCommand("Reopen Closed Enivronment");

    addNew.addActionListener(this);
    close.addActionListener(this);
    delete.addActionListener(this);
    reopen.addActionListener(this);

    add(addNew);
    addSeparator();
    add(close);
    add(delete);

    addSeparator();
    add(reopen);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:28,代码来源:TestDataComponent.java

示例8: ZoomMenu

import javax.swing.JMenuItem; //导入方法依赖的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

示例9: createTablePopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void createTablePopupMenu() {
	pm = new JPopupMenu();
	JMenuItem mi = new JMenuItem("Select Matching Cells");
	mi.setActionCommand("match");
	mi.addActionListener(this);
	pm.add(mi);
	pm.addSeparator();
	createSavePopupMenuItems();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:10,代码来源:CustomDB.java

示例10: createMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public static JMenuItem createMenuItem(String action, ActionListener actionlistener) {
    JMenuItem btn = new JMenuItem();
    btn.setActionCommand(action);
    btn.setText(action);
    btn.addActionListener(actionlistener);
    return btn;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:8,代码来源:Utils.java

示例11: addRoleItems

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Add menu items for role manipulation for a unit.
 *
 * Note "clear speciality" is here too to keep it well separated from
 * other items.
 *
 * @param unitLabel The {@code UnitLabel} specifying the unit.
 * @return True if menu items were added and a separator is now needed.
 */
private boolean addRoleItems(final UnitLabel unitLabel) {
    final Specification spec = freeColClient.getGame().getSpecification();
    final Unit unit = unitLabel.getUnit();
    final Role role = unit.getRole();
    final int roleCount = unit.getRoleCount();
    boolean separatorNeeded = false;

    UnitLocation uloc = (unit.isInEurope()) ? unit.getOwner().getEurope()
        : unit.getSettlement();
    if (uloc == null) return false;
    for (Role r : transform(unit.getAvailableRoles(null),
                            r2 -> r2 != role)) {
        JMenuItem newItem;
        if (r.isDefaultRole()) { // Always valid
            newItem = createRoleItem(unitLabel, role, roleCount, r, 0, 0);
        } else {
            newItem = null;
            for (int count = r.getMaximumCount(); count > 0; count--) {
                List<AbstractGoods> req = unit.getGoodsDifference(r, count);
                try {
                    int price = uloc.priceGoods(req);
                    if (unit.getOwner().checkGold(price)) {
                        newItem = createRoleItem(unitLabel, role, roleCount,
                                                 r, count, price);
                        break;
                    }
                } catch (FreeColException fce) {
                    continue;
                }
            }
        }
        if (newItem != null) {
            this.add(newItem);
            separatorNeeded = true;
        }
    }

    UnitTypeChange uc = unit.getUnitChange(UnitChangeType.CLEAR_SKILL);
    if (uc != null) {
        if (separatorNeeded) this.addSeparator();
        JMenuItem menuItem = Utility.localizedMenuItem("quickActionMenu.clearSpeciality",
            new ImageIcon(gui.getImageLibrary().getTinyUnitImage(uc.to)));
        menuItem.setActionCommand(UnitAction.CLEAR_SPECIALITY.toString());
        menuItem.addActionListener(unitLabel);
        this.add(menuItem);
        if (unit.getLocation() instanceof Building
            && !((Building)unit.getLocation()).canAddType(uc.to)) {
            menuItem.setEnabled(false);
        }
        separatorNeeded = true;
    }
    return separatorNeeded;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:63,代码来源:QuickActionMenu.java

示例12: create

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private JMenuItem create(String text, String actionCommand) {
    JMenuItem menuItem = Utils.createMenuItem(text, TestsetComponent.this);
    menuItem.setActionCommand(actionCommand);
    return menuItem;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:6,代码来源:TestsetComponent.java

示例13: createUnitMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Creates a popup menu for a Unit.
 *
 * @param unitLabel The {@code UnitLabel} to create items for.
 */
private void createUnitMenu(final UnitLabel unitLabel) {
    final Unit unit = unitLabel.getUnit();

    this.setLabel("Unit");
    ImageIcon unitIcon = new ImageIcon(gui.getImageLibrary()
        .getSmallUnitImage(unit));
    JMenuItem name = new JMenuItem(unit.getDescription(Unit.UnitLabelType.NATIONAL)
        + " (" + Messages.message("colopedia") + ")", unitIcon);
    name.setActionCommand(UnitAction.COLOPEDIA.toString());
    name.addActionListener(unitLabel);
    this.add(name);
    this.addSeparator();

    if (addCarrierItems(unitLabel)) this.addSeparator();

    if (unit.isInEurope()) {
        if (addCommandItems(unitLabel)) this.addSeparator();
        if (addBoardItems(unitLabel, unit.getOwner().getEurope())) {
            this.addSeparator();
        }
    } else if (unit.hasTile()) {
        Colony colony = unit.getLocation().getTile().getColony();
        if (colony != null) {
            if (addTileItem(unitLabel)) this.addSeparator();
            if (addWorkItems(unitLabel)) this.addSeparator();
            if (unit.isInColony()
                && addEducationItems(unitLabel)) this.addSeparator();
            if (unit.isInColony() && colony.canReducePopulation()) {
                JMenuItem menuItem = Utility.localizedMenuItem("quickActionMenu.leaveTown");
                menuItem.setActionCommand(UnitAction.LEAVE_TOWN.toString());
                menuItem.addActionListener(unitLabel);
                this.add(menuItem);
                addBoardItems(unitLabel, colony.getTile());
                this.addSeparator();
            } else {
                if (addCommandItems(unitLabel)) this.addSeparator();
                if (addBoardItems(unitLabel, colony.getTile())) {
                    this.addSeparator();
                }
            }
        } else {
            if (addCommandItems(unitLabel)) this.addSeparator();
        }
    }

    if (unit.hasAbility(Ability.CAN_BE_EQUIPPED)) {
        if (addRoleItems(unitLabel)) this.addSeparator();
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:55,代码来源:QuickActionMenu.java

示例14: init

import javax.swing.JMenuItem; //导入方法依赖的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();

    JMenu resetStatus = new JMenu("Change Status");

    JMenuItem noRun = Utils.createMenuItem("NoRun", actionListener);
    noRun.setActionCommand("Change Status");
    noRun.setIcon(Canvas.EmptyIcon);
    resetStatus.add(noRun);

    JMenuItem passed = Utils.createMenuItem("Passed", actionListener);
    passed.setActionCommand("Change Status");
    resetStatus.add(passed);

    JMenuItem failed = Utils.createMenuItem("Failed", actionListener);
    failed.setActionCommand("Change Status");
    resetStatus.add(failed);

    add(resetStatus);

    changeBrowser = new JMenu("Change Browser");
    add(changeBrowser);
    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("Go To TestCase", "Alt+Click", null, actionListener));
    addSeparator();
    add(saveMenuItem = Utils.createMenuItem("Save", "Ctrl+S", Keystroke.SAVE, actionListener));
    add(Utils.createMenuItem("Reload", "F5", Keystroke.F5, actionListener));
    saveMenuItem.setIcon(Canvas.EmptyIcon);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:45,代码来源:TestSetPopupMenu.java


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