javax.swing.JMenuBar.getComponentCount()方法的使用及代码示例

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

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

JMenuBar.getComponentCount介绍

暂无

代码示例

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

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

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

/**
 * Returns all occurences of the specified string in the menus and menu
 * items of the associated menu bar.
 * 
 * @param searchPattern
 *            Pattern to search (no wildcards yet).
 * @return All occurences of the specified string in the menus and menu
 *         items of the associated menu bar.
 */
private LinkedList<SearchResult> findOccurences(String searchPattern) {
  LinkedList<SearchResult> result = new LinkedList<SearchResult>();
  LinkedList<JMenu> currentPath = new LinkedList<JMenu>();
  for (int i = 0; i < jcomp.getComponentCount(); i++) {
    Component component = jcomp.getComponent(i);
    if (component instanceof JMenu) {
      JMenu menu = (JMenu) component;
      this.checkMenu(currentPath, menu, searchPattern, result);
    }
  }
  return result;
}

代码示例来源:origin: net.java.openjdk.cacio/cacio-shared

public void addMenu(Menu m) {
  JMenuBar jmb = getSwingMenu();
  // If we have a help menu, add new menus add the last - 1 position,
  // otherwise we append at the end.
  if (helpMenu != null) {
    jmb.add(getSwingMenu(m), jmb.getComponentCount() - 1);
  } else {
    jmb.add(getSwingMenu(m));
  }
  // Force re-layout.
  jmb.revalidate();
}

代码示例来源:origin: girtel/Net2Plan

new_parent.setMnemonic('T');
} else {
  menubar.add(new_parent, menubar.getComponentCount() - 1);

代码示例来源:origin: girtel/Net2Plan

/**
 * Refresh main menu with currently loaded GUI plugins.
 *
 * @since 0.3.1
 */
public static void refreshMenu() {
  instance.usedKeyStrokes.clear();
  while (instance.menu.getComponentCount() > 2) instance.menu.remove(1);
  for (Class<? extends Plugin> plugin : PluginSystem.getPlugins(IGUIModule.class)) {
    try {
      IGUIModule pluginInstance = ((Class<? extends IGUIModule>) plugin).newInstance();
      String menuName = pluginInstance.getMenu();
      JMenuItem item = getCurrentMenu(instance.menu, null, menuName);
      item.addActionListener(instance);
      KeyStroke keystroke = pluginInstance.getKeyStroke();
      if (keystroke != null && !instance.usedKeyStrokes.contains(keystroke)) {
        item.setAccelerator(keystroke);
        instance.usedKeyStrokes.add(keystroke);
      }
      instance.itemObject.put(item, plugin);
    } catch (NoClassDefFoundError e) {
      throw new Net2PlanException("Class " + e.getMessage() + " cannot be found. A dependence for " + plugin.getSimpleName() + " is missing?");
    } catch (Throwable e) {
      throw new RuntimeException(e);
    }
  }
  instance.menu.revalidate();
}

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

Component removed = null;
for (int i = 0; i < MenuSearchWidget.this.jcomp
    .getComponentCount(); i++) {
  if (MenuSearchWidget.this.jcomp.getComponent(i) instanceof SearchPanel) {
    removed = MenuSearchWidget.this.jcomp
  MenuSearchWidget.this.jcomp
      .add(removed, MenuSearchWidget.this.jcomp
          .getComponentCount());

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

/**
 * Overrides the base class version in order to create and configure the VISAT's main pane.
 */
@Override
protected JComponent createMainPane() {
  final JMenuBar menuBar = getMainFrame().getJMenuBar();
  JMenu windowMenu = null;
  for (int i = 0; i < menuBar.getComponentCount(); i++) {
    final Component component = menuBar.getComponent(i);
    if (component instanceof JMenu && "window".equals(component.getName())) {
      windowMenu = (JMenu) menuBar.getComponent(i);
    }
  }
  desktopPane.setWindowMenu(windowMenu);
  return desktopPane;
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

mb.add(editMenu, Math.min(1, mb.getComponentCount()));
mb.add(viewMenu, Math.min(2, mb.getComponentCount()));

代码示例来源:origin: net.sf.cuf/cuf-swing

index = mMenuBar.getComponentCount() + index + 1;
mMenuBar.add(menuItem, index);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

mb.add(editMenu, Math.min(1, mb.getComponentCount()));
mb.add(viewMenu, Math.min(2, mb.getComponentCount()));

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

mb.add(editMenu, Math.min(1, mb.getComponentCount()));
mb.add(viewMenu, Math.min(2, mb.getComponentCount()));

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

.getLafSupport();
this.searchPanel = new SearchPanel(this.jcomp);
this.jcomp.add(searchPanel, this.jcomp.getComponentCount());
this.searchPanel.setVisible(lafSupport.toInstallMenuSearch(this.jcomp));

相关文章