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


Java JMenuItem.setAction方法代码示例

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


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

示例1: KMeanScatterPopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanScatterPopupMenu() {
	restore = new JMenuItem("Original view");
	saveAs = new JMenuItem("Save as...");
	clusters = new JMenu("Clusters");
	printClusterInfo = new JMenuItem("Save info...");
	point = new JMenu("Point size");
	for (int i = 0; i < 5; i++) {
		JMenuItem m = new JMenuItem();
		m.setAction(commonActionSize);
		m.setText("Size " + Integer.toString((i + 1)));
		point.add(m);
	}

	this.add(restore);
	this.addSeparator();
	this.add(point);
	this.addSeparator();
	this.add(saveAs);
	this.addSeparator();
	this.add(printClusterInfo);
	this.addSeparator();
	this.add(clusters);
	addListeners();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:KMeanScatter.java

示例2: ScatterPopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public ScatterPopupMenu() {
	restore = new JMenuItem("Original view");
	saveAs = new JMenuItem("Save as...");
	point = new JMenu("Point size");
	for (int i = 0; i < 5; i++) {
		JMenuItem m = new JMenuItem();
		m.setAction(commonActionSize);
		m.setText("Size " + Integer.toString((i + 1)));
		point.add(m);
	}

	this.add(restore);
	this.addSeparator();
	this.add(point);
	this.addSeparator();
	this.add(saveAs);
	addListeners();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:19,代码来源:Scatter.java

示例3: KMeanSingleClusterScatterPopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanSingleClusterScatterPopupMenu() {
	restore = new JMenuItem("Original view");
	saveAs = new JMenuItem("Save as...");
	clusters = new JMenu("Cluster");
	printClusterInfo = new JMenuItem("Save info...");
	point = new JMenu("Point size");
	for (int i = 0; i < 3; i++) {
		JMenuItem m = new JMenuItem();
		m.setAction(commonActionSize);
		m.setText("Size " + Integer.toString((i + 1)));
		point.add(m);
	}

	this.add(restore);
	this.addSeparator();
	this.add(point);
	this.addSeparator();
	this.add(saveAs);
	this.addSeparator();
	this.add(printClusterInfo);
	this.addSeparator();
	this.add(clusters);
	addListeners();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:KMeanSingleClusterScatter.java

示例4: KMeanScatterPopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanScatterPopupMenu() {
	restore = new JMenuItem("Original view");
	saveAs = new JMenuItem("Save as...");
	clusters = new JMenu("Cluster");
	printClusterInfo = new JMenuItem("Save info...");
	point = new JMenu("Point size");
	for (int i = 0; i < 3; i++) {
		JMenuItem m = new JMenuItem();
		m.setAction(commonActionSize);
		m.setText("Size " + Integer.toString((i + 1)));
		point.add(m);
	}
	this.add(restore);
	this.addSeparator();
	this.add(point);
	this.addSeparator();
	this.add(saveAs);
	this.addSeparator();
	this.add(printClusterInfo);
	this.addSeparator();
	this.add(clusters);
	addListeners();

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:FuzzyKSingleClusterScatter.java

示例5: KMeanScatterPopupMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public KMeanScatterPopupMenu() {
	restore = new JMenuItem("Original view");
	saveAs = new JMenuItem("Save as...");
	//clusters = new JMenu("Clusters");
	printClusterInfo = new JMenuItem("Save info...");
	point = new JMenu("Point size");
	for (int i = 0; i < 5; i++) {
		JMenuItem m = new JMenuItem();
		m.setAction(commonActionSize);
		m.setText("Size " + Integer.toString((i + 1)));
		point.add(m);
	}
	this.add(restore);
	this.addSeparator();
	this.add(point);
	this.addSeparator();
	this.add(saveAs);
	this.addSeparator();
	this.add(printClusterInfo);
	//this.addSeparator();
	//this.add(clusters);
	addListeners();

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:KFuzzyScatter.java

示例6: setActionMenuBar

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void setActionMenuBar(String menuItem, Action action) {
	for (int i = 0; i < mMenuBar.getMenuCount(); i++) {
		JMenu menu = mMenuBar.getMenu(i);
		for (int j = 0; j < menu.getMenuComponentCount(); j++) {
			Component component = menu.getMenuComponent(j);
			if (component instanceof JMenuItem) {
				JMenuItem item = (JMenuItem) component;
				String description = (String) item.getAction().getValue(Action.SHORT_DESCRIPTION);
				if (description.equals(menuItem)) {
					item.setAction(action);
					item.setText(menuItem);
					break;
				}
			}
		}
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:JWatWizard.java

示例7: getPopupPresenter

import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
@Messages({"ACT_Show=Show in POM", 
    "# {0} - artifactid of a project",
    "ACT_Current=Current: {0}",
    "# {0} - artifactid of a project",
    "ACT_PARENT=Parent: {0}"})
public JMenuItem getPopupPresenter() {
    JMenu menu = new JMenu();
    menu.setText(ACT_Show());
    POMCutHolder pch = node.getLookup().lookup(POMCutHolder.class);
    POMModel[] mdls = pch.getSource();
    Object[] val = pch.getCutValues();
    int index = 0;
    for (POMModel mdl : mdls) {
        String artifact = mdl.getProject().getArtifactId();
        JMenuItem item = new JMenuItem();
        item.setAction(new SelectAction(node, index));
        if (index == 0) {
            item.setText(ACT_Current(artifact != null ? artifact : "project"));
        } else {
            item.setText(ACT_PARENT(artifact != null ? artifact : "project"));
        }
        item.setEnabled(/* #199345 */index < val.length && val[index] != null);
        menu.add(item);
        index++;
    }
    return menu;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:POMModelVisitor.java

示例8: setMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/** Sets the state of JMenuItem*/
protected @Override void setMenu(){
    
    ActionMap am = getContextActionMap();
    Action action = null;
    if (am != null) {
        action = am.get(getActionName());
    }
    
    JMenuItem presenter = getMenuPresenter();
    Action presenterAction = presenter.getAction();
    if (presenterAction == null){
        presenter.setAction(this);
        presenter.setToolTipText(null); /* bugfix #62872 */ 
        menuInitialized = false;
    } 
    else {
        if (!this.equals(presenterAction)){
            presenter.setAction(this);
            presenter.setToolTipText(null); /* bugfix #62872 */
            menuInitialized = false;
        }
    }

    if (!menuInitialized){
        Mnemonics.setLocalizedText(presenter, getMenuItemText());
        menuInitialized = true;
    }

    presenter.setEnabled(action != null);
    JTextComponent comp = Utilities.getFocusedComponent();
    if (comp != null && comp instanceof JEditorPane){
        addAccelerators(this, presenter, comp);
    } else {
        presenter.setAccelerator(getDefaultAccelerator());
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CompletionActionsMainMenu.java

示例9: showPopup

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void showPopup(JComponent source) {
  final JPopupMenu popup = new JPopupMenu();

  for (Enumeration<?> e = addressBook.elements(); e.hasMoreElements();) {
    final AddressBookEntry entry = (AddressBookEntry) e.nextElement();
    final JMenuItem item = new JMenuItem(entry.toString());
    final AbstractAction action = new MenuAction(entry);
    item.setAction(action);
    item.setIcon(entry.getIcon(IconFamily.SMALL));
    popup.add(item);
  }
  popup.show(source, 0, 0);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:ServerAddressBook.java


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