當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。