javax.swing.JMenuItem.getName()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中javax.swing.JMenuItem.getName()方法的一些代码示例,展示了JMenuItem.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.getName()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:getName

JMenuItem.getName介绍

暂无

代码示例

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public String toString() {
  return String.format("%s [%s]", super.getName() != null ? super.getName() : "", getClass().getSimpleName());
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = JS_NAME_DOC)
@Override
public String getName() {
  return super.getName();
}

代码示例来源:origin: sensepost/yeti

@Override
public void pluginMenuEvent(ActionEvent evt) {
  if (evt.getSource().getClass() == JMenuItem.class) {
    try {
      String scriptName = (((JMenuItem) evt.getSource()).getName());
      this.executeScript(scriptName);
    } catch (FileNotFoundException | ScriptException ex) {
      Logger.getLogger(AttributePluginManager.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core

/**
 * Get the recent file for the menu item
 */
private File getRecentFile(ActionEvent e) {
  JMenuItem menuItem = (JMenuItem)e.getSource();
  // Get the preference for the recent files
  return new File(getRecentFile(Integer.parseInt(menuItem.getName())));
}

代码示例来源:origin: sensepost/yeti

@Override
public void pluginMenuEvent(ActionEvent evt) {
  if (evt.getSource().getClass() == JMenuItem.class) {
    try {
      String scriptName = (((JMenuItem) evt.getSource()).getName());
      this.executeScript(scriptName);
    } catch (FileNotFoundException | ScriptException ex) {
      Logger.getLogger(AttributePluginManager.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
}

代码示例来源:origin: sensepost/yeti

private void pluginMenuEvent(ActionEvent evt) {
  if (evt.getSource().getClass() == JMenuItem.class) {
    String scriptName = (((JMenuItem) evt.getSource()).getName());
    currentWorkflowController.startCollector(scriptName);
  }
}

代码示例来源:origin: sensepost/yeti

@Override
public void pluginMenuEvent(ActionEvent evt) {
  if (evt.getSource().getClass() == JMenuItem.class) {
    try {
      String scriptName = (((JMenuItem) evt.getSource()).getName());
      this.executeScript(scriptName);
    } catch (FileNotFoundException | ScriptException ex) {
      Logger.getLogger(AttributePluginManager.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
}

代码示例来源:origin: sensepost/yeti

@Override
  public void pluginMenuEvent(ActionEvent evt) {
    if (evt.getSource().getClass() == JMenuItem.class) {
      try {
        String scriptName = (((JMenuItem) evt.getSource()).getName());
        this.executeScript(scriptName);
      } catch (FileNotFoundException ex) {
        Logger.getLogger(ReportPluginManager.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ScriptException ex) {
        Logger.getLogger(ReportPluginManager.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

  }
}

代码示例来源:origin: stackoverflow.com

private void init(JMenu blocks) {
  for (int i=0; i < 9; i++){

  JMenuItem blockName = new JMenuItem(i+"");
  blockName.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent arg0) {
       handleAction(arg0);
     }
   });
  blocks.add(blockName);
 }
}

  public void handleAction(ActionEvent event) {

    Object source = event.getSource(); 

    if(source instanceof JMenuItem) {
      JMenuItem item = (JMenuItem) source;
      System.out.println(item.getName());
    ) 
  }

代码示例来源:origin: bcdev/beam

public static int findMenuItemPosition(JPopupMenu popupMenu, String name) {
  int n = popupMenu.getComponentCount();
  for (int i = 0; i < n; i++) {
    Component c = popupMenu.getComponent(i);
    if (c instanceof JMenuItem) {
      JMenuItem menuItem = (JMenuItem) c;
      if (name.equals(menuItem.getName())) {
        return i;
      }
    }
  }
  return -1;
}

代码示例来源:origin: senbox-org/snap-desktop

public static int findMenuItemPosition(JPopupMenu popupMenu, String name) {
  int n = popupMenu.getComponentCount();
  for (int i = 0; i < n; i++) {
    Component c = popupMenu.getComponent(i);
    if (c instanceof JMenuItem) {
      JMenuItem menuItem = (JMenuItem) c;
      if (name.equals(menuItem.getName())) {
        return i;
      }
    }
  }
  return -1;
}

代码示例来源:origin: JChemPaint/jchempaint

/**
 * Update the menu bars and toolbars to current language.
 */
public void updateMenusWithLanguage() {
  menuTextMaker.init(guistring);
  Iterator<String> it = buttons.keySet().iterator();
  while(it.hasNext()){
    String key = it.next();
    JButton button = buttons.get(key);
    button.setToolTipText(menuTextMaker.getText(key + JCPAction.TIPSUFFIX));
  }
  Iterator<JMenuItem> it2 = menus.iterator();
  while(it2.hasNext()){
    JMenuItem button = it2.next();
    button.setText(JCPMenuTextMaker.getInstance(guistring).getText(button.getName().charAt(button.getName().length()-1)=='2' ? button.getName().substring(0,button.getName().length()-1) : button.getName()));
  }
  it = popupmenuitems.keySet().iterator();
  while(it.hasNext()){
    String key = it.next();
    JChemPaintPopupMenu button = popupmenuitems.get(key);
    ((JMenuItem)button.getComponent(0)).setText(menuTextMaker.getText(key.substring(0,key.length()-5) + "MenuTitle"));
  }
  if(insertTextPanel!=null){
    insertTextPanel.updateLanguage();
  }
}

代码示例来源:origin: net.sf.doolin/doolin-gui

/**
 * Utility method that looks for a menu item using the
 * {@link JMenuItem#getName() name} of the menu item as an identifier.
 * 
 * @param name
 *            Name to find
 * @return Found {@link JMenuItem} or <code>null</code>
 */
protected JMenuItem getMenuItemByName(String name) {
  int count = this.menu.getItemCount();
  for (int i = 0; i < count; i++) {
    JMenuItem menuItem = this.menu.getItem(i);
    if (menuItem != null
        && StringUtils.equals(name, menuItem.getName())) {
      return menuItem;
    }
  }
  return null;
}

代码示例来源:origin: net.sf.doolin/doolin-gui

/**
 * Utility method that looks for a sub-menu using the
 * {@link JMenu#getName() name} of the menu as an identifier.
 * 
 * @param name
 *            Name to find
 * @return Found {@link JMenu} or <code>null</code>
 */
protected JMenu getMenuByName(String name) {
  int count = this.menu.getItemCount();
  for (int i = 0; i < count; i++) {
    JMenuItem menuItem = this.menu.getItem(i);
    if (menuItem instanceof JMenu
        && StringUtils.equals(name, menuItem.getName())) {
      return (JMenu) menuItem;
    }
  }
  return null;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public static JMenuItem getMenuItem(MenuElement _menu, String _name)
{
 JMenuItem r=null;
 //synchronized(_menu)
 {
  MenuElement[] c=_menu.getSubElements();
  for(int i=0; i<c.length; i++)
  {
 if(c[i] instanceof JMenuItem)
 {
  JMenuItem m=(JMenuItem)c[i];
  // System.err.println(m.getName());
  if(m.getName().equals("mi"+_name))
   { r=m; break; }
 }
 r=getMenuItem(c[i],_name);
 if(r!=null) break;
  }
 }
 return r;
}

代码示例来源:origin: baishui2004/common_gui_tools

public void actionPerformed(ActionEvent event) {
  JMenuItem item = (JMenuItem) event.getSource();
  Integer pluginId = Integer.parseInt(item.getName());

代码示例来源:origin: org.activecomponents.jadex/jadex-editor-bpmn

public void actionPerformed(ActionEvent e)
  {
    String mode = ((JMenuItem) e.getSource()).getName();
    ((MActivity) gateway.getBpmnElement()).setActivityType(mode);
    modelcontainer.getGraph().refreshCellView(gateway);
  }
};

代码示例来源:origin: org.activecomponents.jadex/jadex-editor-bpmn

public void actionPerformed(ActionEvent e)
  {
    String mode = ((JMenuItem) e.getSource()).getName();
    mxICell parent = ((mxICell) source).getParent();
    if (source instanceof VActivity && ((MActivity) ((VActivity) source).getBpmnElement()).isEventHandler())
    {
      parent = parent.getParent();
    }
    
    target = SCreationController.createActivity(modelcontainer,
                      mode,
                      parent,
                      loc,
                      false);
    actionlistener.actionPerformed(e);
  }
};

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

name = item.getName ();
if ("Links".equals (name))
  mStringBean.setLinks (item.isSelected ());
name = ((JMenuItem)source).getName ();
if ("Back".equals (name))

代码示例来源:origin: org.activecomponents.jadex/jadex-editor-bpmn

public void actionPerformed(ActionEvent e)
      {
        String mode = ((JMenuItem) e.getSource()).getName();
        String type = ModelContainer.ACTIVITY_MODES_TO_TYPES.get(mode);
        if (type == null)
        {
          type = mode;
        }
        
        ((MActivity) event.getBpmnElement()).setActivityType(type);
        ((MActivity) event.getBpmnElement()).setThrowing(mode.endsWith(ModelContainer.THROWING_EVENT));
//                modelcontainer.setPropertyPanel(SPropertyPanelFactory.createPanel(event, modelcontainer));
        modelcontainer.setPropertyPanel(modelcontainer.getSettings().getPropertyPanelFactory().createPanel(modelcontainer, event));
        modelcontainer.getGraph().refreshCellView(event);
      }
    };

相关文章

JMenuItem类方法