javax.swing.JMenu.getMenuComponentCount()方法的使用及代码示例

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

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

JMenu.getMenuComponentCount介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

/**
 * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>.
 *
 * @param self a JMenu
 * @return the menu component count of the menu
 * @since 1.6.4
 */
public static int size(JMenu self) {
  return self.getMenuComponentCount();
}

代码示例来源:origin: ron190/jsql-injection

@Override
public void mouseClicked(MouseEvent e) {
  if (SwingUtilities.isRightMouseButton(e)) {
    Component componentSource = (Component) e.getSource();
    JPopupMenu menu = new JPopupMenu();
    for (int position = 0 ; position < MediatorGui.menubar().getMenuView().getMenuComponentCount() ; position++) {
      // Fix #35348: SerializationException on clone()
      try {
        JMenuItem itemMenu = (JMenuItem) SerializationUtils.clone(MediatorGui.menubar().getMenuView().getMenuComponent(position));
        menu.add(itemMenu);
        
        final int positionFinal = position;
        itemMenu.addActionListener(actionEvent -> MediatorGui.tabManagers().setSelectedIndex(positionFinal));
      } catch (SerializationException ex) {
        LOGGER.error(ex, ex);
      }
    }
    menu.show(componentSource, e.getX(), e.getY());
    
    menu.setLocation(
      ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT
      ? e.getXOnScreen() - menu.getWidth()
      : e.getXOnScreen(),
      e.getYOnScreen()
    );
  }
}

代码示例来源:origin: org.codehaus.groovy/groovy-swing

/**
 * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>.
 *
 * @param self a JMenu
 * @return the menu component count of the menu
 * @since 1.6.4
 */
public static int size(JMenu self) {
  return self.getMenuComponentCount();
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>.
 *
 * @param self a JMenu
 * @return the menu component count of the menu
 * @since 1.6.4
 */
public static int size(JMenu self) {
  return self.getMenuComponentCount();
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

/**
 * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>.
 *
 * @param self a JMenu
 * @return the menu component count of the menu
 * @since 1.6.4
 */
public static int size(JMenu self) {
  return self.getMenuComponentCount();
}

代码示例来源:origin: openpnp/openpnp

private void setReticleOptionsMenu(JMenu menu) {
  if (reticleOptionsMenu != null) {
    reticleMenu.remove(reticleMenu.getMenuComponentCount() - 1);
    reticleMenu.remove(reticleMenu.getMenuComponentCount() - 1);
  }
  if (menu != null) {
    reticleMenu.addSeparator();
    reticleMenu.add(menu);
  }
  reticleOptionsMenu = menu;
}

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

@Override
@ScriptFunction(jsDoc = MENU_COUNT_JSDOC)
public int getCount() {
  return super.getMenuComponentCount();
}

代码示例来源:origin: robo-code/robocode

public WindowMenuItem(EditWindow window, JMenu parentMenu) {
  super();
  this.window = window;
  this.parentMenu = parentMenu;
  type = REGULAR_WINDOW;
  parentMenu.add(this, parentMenu.getMenuComponentCount() - SUBSEQUENT_WINDOW_MENU_ITEMS);
  addActionListener(this);
}

代码示例来源:origin: cpesch/RouteConverter

private static <T extends Component> T findMenuComponent(JMenu menu, String menuComponentName, Class<T> componentClass) {
  for (int i = 0; i < menu.getMenuComponentCount(); i++) {
    Component component = menu.getMenuComponent(i);
    if (menuComponentName.equals(component.getName()) && componentClass.isInstance(component))
      return componentClass.cast(component);
  }
  return null;
}

代码示例来源:origin: eugener/oxbow

@Override
public void addSeparator() {
  int count = target.getMenuComponentCount();
  boolean canAddSeparator = count != 0 &&
      target.getMenuComponent(count-1).getClass() != JPopupMenu.Separator.class;
  if ( canAddSeparator ) target.addSeparator();
}

代码示例来源:origin: org.bidib.org.oxbow/swingbits

@Override
public void addSeparator() {
  int count = target.getMenuComponentCount();
  boolean canAddSeparator = count != 0 &&
      target.getMenuComponent(count-1).getClass() != JPopupMenu.Separator.class;
  if ( canAddSeparator ) target.addSeparator();
}

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

public void update(JMenu menu)
{
  Vector macroVector = Macros.getMacroHierarchy();
  int count = menu.getMenuComponentCount();
  createMacrosMenu(menu,macroVector,0);
  if(count == menu.getMenuComponentCount())
  {
    JMenuItem mi = new JMenuItem(jEdit.getProperty(
      "no-macros.label"));
    mi.setEnabled(false);
    menu.add(mi);
  }
} //}}}

代码示例来源:origin: Audiveris/audiveris

/**
   * Remove any potential orphan separator at the end of the menu.
   *
   * @param menu the menu to purge
   */
  public static void trimSeparator (JMenu menu)
  {
    int count = menu.getMenuComponentCount();

    if ((count > 0) && menu.getMenuComponent(count - 1) instanceof JSeparator) {
      menu.remove(count - 1);
    }
  }
}

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

protected void enableUserDefined() {
  DockedTypeDescriptor descriptor = (DockedTypeDescriptor) toolWindow.getTypeDescriptor(ToolWindowType.DOCKED);
  if (old != null) {
    popupMenu.remove(old);
  }
  JMenu menu = descriptor.getToolsMenu();
  if (menu.getMenuComponentCount() > 0) {
    popupMenu.add(menu, 4);
    old = menu;
  }
}

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

JMenuBar menubar1 = getJMenuBar();
for (int i = 0; i < menubar1.getMenuCount(); i++) {
  JMenu menu1 = menubar1.getMenu(i);
  System.out.println("Menu:" + menu1.getText());
  for (int j = 0; j < menu1.getMenuComponentCount(); j++) {
    java.awt.Component comp = menu1.getMenuComponent(j);
    if (comp instanceof JMenuItem) {
      JMenuItem menuItem1 = (JMenuItem) comp;
      System.out.println("MenuItem:" + menuItem1.getText());
    }
  }
}

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

private static void updateMenu(final JMenu _m,final String actionCommand){
 for (int i = _m.getMenuComponentCount() - 1; i >= 0; i--) {
  if (_m.getMenuComponent(i) instanceof JMenuItem) {
   final JMenuItem it = (JMenuItem) _m.getMenuComponent(i);
   it.setSelected(it.getActionCommand().equals(actionCommand));
  }
 }
}

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

JMenuBar menubar1 = getJMenuBar();
for (int i = 0; i < menubar1.getMenuCount(); i++) {
  JMenu menu1 = menubar1.getMenu(i);
  System.out.println("Menu:" + menu1.getText());
  for (int j = 0; j < menu1.getMenuComponentCount(); j++) {
    java.awt.Component comp = menu1.getMenuComponent(j);
    if (comp instanceof JMenuItem) {
      JMenuItem menuItem1 = (JMenuItem) comp;
      System.out.println("MenuItem:" + menuItem1.getText());
    }
  }
}

代码示例来源:origin: cpesch/RouteConverter

public void contentsChanged(ListDataEvent e) {
    for (int i = e.getIndex0(); i <= e.getIndex1(); i++) {
      if (i >= 0 && i < menu.getMenuComponentCount()) {
        BaseRoute route = formatAndRoutesModel.getRoute(i);
        JMenuItem menuItem = (JMenuItem) menu.getMenuComponent(i);
        menuItem.setText(shortenRouteName(route));
      }
    }
  }
});

代码示例来源:origin: cytoscape.coreplugins/linkout

/**
 * Print menu items - for debugging
 */
private void printMenu(JMenu jm) {
  int count = jm.getMenuComponentCount();
  for (int i = 0; i < count; i++) {
    if (jm.getItem(i).getClass().getName().equals("javax.swing.JMenuItem")) {
      logger.debug(jm.getItem(i).getText());
      continue;
    } else {
      logger.debug(jm.getItem(i).getText() + "--");
      printMenu((JMenu) jm.getItem(i));
    }
  }
}

代码示例来源:origin: cpesch/RouteConverter

public void intervalRemoved(ListDataEvent e) {
  for (int i = e.getIndex1(); i >= e.getIndex0(); i--) {
    JMenuItem menuItem = i < menu.getMenuComponentCount() ? (JMenuItem) menu.getMenuComponent(i) : null;
    if (menuItem != null) {
      MergePositionListAction action = (MergePositionListAction) menuItem.getAction();
      action.dispose();
      menuItem.setAction(null);
    }
    if (menu.getItemCount() > i)
      menu.remove(i);
  }
  menu.setEnabled(formatAndRoutesModel.getSize() > 1);
}

相关文章