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

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

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

JMenu.getComponentCount介绍

暂无

代码示例

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

public JMenu getExtraSubMenu(JMenu parentComponent) {
  final Component lastComponent = parentComponent.getComponent(parentComponent.getComponentCount()-1);
  if (isExtraSubMenu(lastComponent))
    return (JMenu) lastComponent;
  else
    return null;
}

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

public boolean hasExtraSubMenu(final JMenu menu) {
  final Component lastComponent = menu.getComponent(menu.getComponentCount()-1);
  return isExtraSubMenu(lastComponent);
}

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

@Override
public JMenuItem getMenuPresenter() {
  List<File> openedFiles = OpenProductAction.getOpenedProductFiles();
  List<String> pathList = getRecentProductPaths().get();
  final Preferences preference = SnapApp.getDefault().getPreferences();
  int maxFileList = preference.getInt(UiBehaviorController.PREFERENCE_KEY_LIST_FILES_TO_REOPEN,
      DEFAULT_MAX_FILE_LIST_REOPEN);
  // Add "open recent product file" actions
  JMenu menu = new JMenu(Bundle.CTL_ReopenProductActionMenuText());
  pathList.stream().limit(maxFileList).forEach(path->{
    if (!openedFiles.contains(new File(path))) {
      JMenuItem menuItem = new JMenuItem(path);
      OpenProductAction openProductAction = new OpenProductAction();
      openProductAction.setFile(new File(path));
      menuItem.addActionListener(openProductAction);
      menu.add(menuItem);
    }
  });
  // Add "Clear List" action
  if (menu.getComponentCount() > 0 || pathList.size() > 0) {
    menu.addSeparator();
    JMenuItem menuItem = new JMenuItem(Bundle.CTL_ClearListActionMenuText());
    menuItem.addActionListener(e -> getRecentProductPaths().clear());
    menu.add(menuItem);
  }
  return menu;
}

代码示例来源:origin: MegaMek/mekhq

if (unsorted.getComponentCount() > 0 || unsorted.getItemCount() > 0) {
  menu.add(unsorted);
  menu.setEnabled(true);

相关文章