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


Java JMenuItem.setName方法代码示例

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


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

示例1: configureMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
        //Intentionally use enabled property
        item.setVisible(enabled);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractContextMenuFactory.java

示例2: configureMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
//        System.err.println("  item text is " + item.getText());
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
//        System.err.println("action " + action + (enabled ? " enabled" : " disabled"));
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
//        System.err.println("action " + action + (visible ? " visible" : " invisible"));
        item.setVisible(visible);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AbstractMenuFactory.java

示例3: getJMenuItem4NetworkComponentProperties

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
   * Returns a JMenueItem for the properties of a NetworkComponent.
   *
   * @param networkComponent the NetworkComponent
   * @return the JMenueItem for the specified NetworkComponent
   */
  private JMenuItem getJMenuItem4NetworkComponentProperties(NetworkComponent networkComponent) {
  	
  	final NetworkComponent networkComponent2Edit = networkComponent;
  	
  	JMenuItem jMenuItem = new JMenuItem();
  	jMenuItem.setName(MENU_ITEM_NAME_PREFIX + "_JMenuItem_" + networkComponent.getId());
  	jMenuItem.setText(Language.translate("Edit Properties", Language.EN));
  	jMenuItem.setIcon(new ImageIcon(getClass().getResource(IMAGE_PATH + "Properties.png")));
  	jMenuItem.addActionListener(new ActionListener() {
	@Override
	public void actionPerformed(ActionEvent e) {
  			NetworkModelNotification nmn = new NetworkModelNotification(NetworkModelNotification.NETWORK_MODEL_EditComponentSettings);
  			nmn.setInfoObject(networkComponent2Edit);
  			basicGraphGui.getGraphEnvironmentController().notifyObservers(nmn);
	}
});
  	return jMenuItem;
  }
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:GraphEnvironmentPopupPlugin.java

示例4: populeComandos

import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void populeComandos(JMenuItem menu) {
    super.populeComandos(menu);
    menu.removeAll();
    menu.setEnabled(true);
    String tmp = Editor.fromConfiguracao.getValor("Controler.interface.Diagrama.Command.Eap.Cli.descricao");
    Diagrama.AcaoDiagrama ac = new Diagrama.AcaoDiagrama(this, tmp, "Controler.interface.Diagrama.Command.Eap.Cli.img", tmp, COMM_CLI);
    ac.normal = false;
    JMenuItem mi = new JMenuItem(ac);
    mi.setName(tmp);
    menu.add(mi);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:13,代码来源:DiagramaEap.java

示例5: init

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param
* @return void 
* @throws
 */
private void init()
{
    this.setLayout(new BorderLayout(FormatConst.BORDER_WIDTH, 0));

    txtAra = new JTextArea(FormatConst.AREA_ROWS, 1);
    txtAra.addMouseListener(ma);

    miFmt = new JMenuItem(FormatConst.FORMAT);
    miFmt.setName(FormatConst.FORMAT);
    miFmt.addActionListener(this);

    miCut = new JMenuItem(FormatConst.CUT);
    miCut.setName(FormatConst.CUT);
    miCut.addActionListener(this);

    miCpy = new JMenuItem(FormatConst.COPY);
    miCpy.setName(FormatConst.COPY);
    miCpy.addActionListener(this);

    miClr = new JMenuItem(FormatConst.CLEAR);
    miClr.setName(FormatConst.CLEAR);
    miClr.addActionListener(this);

    miPst = new JMenuItem(FormatConst.PASTE);
    miPst.setName(FormatConst.PASTE);
    miPst.addActionListener(this);
    
    pm = new JPopupMenu();
    pm.add(miFmt);
    pm.addSeparator();
    pm.add(miCut);
    pm.add(miCpy);
    pm.add(miPst);
    pm.addSeparator();
    pm.add(miClr);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new BorderLayout());
    JScrollPane sp = new JScrollPane(txtAra);
    pnlCenter.add(sp);

    this.add(pnlCenter, BorderLayout.CENTER);
}
 
开发者ID:wisdomtool,项目名称:formatter,代码行数:52,代码来源:FormatTxtPanel.java

示例6: addMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
void addMenuItem(String id, JComponent menu) {
	JMenuItem mitem = new JMenuItem(getString(id));
	mitem.setName(id);
	mitem.addActionListener(this);
	menu.add(mitem);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:7,代码来源:XDMMainWindow.java


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