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

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

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

JMenu.getMenuComponents介绍

暂无

代码示例

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

/**
 * Returns an {@link java.util.Iterator} which traverses the JMenu one component at a time.
 *
 * @param self a JMenu
 * @return an Iterator for a JMenu
 * @since 1.6.4
 */
public static Iterator/*<MenuElement>*/ iterator(JMenu self) {
  return DefaultGroovyMethods.iterator(self.getMenuComponents());
}

代码示例来源:origin: chewiebug/GCViewer

/**
   * Returns MenuItem, which is associated with "WATCH" action command.
   * 
   * @return "WATCH" menu item
   */
  public JCheckBoxMenuItem getWatchMenuItem() {
    for (Component component : fileMenu.getMenuComponents()) {
      if (component instanceof JCheckBoxMenuItem
        && ((JCheckBoxMenuItem) component).getActionCommand().equals(ActionCommands.WATCH.toString())) {
        
        return (JCheckBoxMenuItem) component;
      }
    }
    
    throw new IllegalStateException("StayOpenCheckBoxMenuItem with actionCommand '" + ActionCommands.WATCH + "' not found");
  }
}

代码示例来源:origin: apache/pdfbox

/**
 * Add the ActionListener for the menuitems.
 *
 * @param listener ActionListener.
 */
public void addMenuListeners(ActionListener listener)
{
  for (Component comp : menu.getMenuComponents())
  {
    JMenuItem menuItem = (JMenuItem) comp;
    removeActionListeners(menuItem);
    menuItem.addActionListener(listener);
  }
}

代码示例来源:origin: apache/pdfbox

/**
 * Tell the current zoom scale.
 *
 * @return the current zoom scale.
 * @throws IllegalStateException if no zoom menu item is selected.
 */
public static float getZoomScale()
{
  for (Component comp : instance.menu.getMenuComponents())
  {
    ZoomMenuItem menuItem = (ZoomMenuItem) comp;
    if (menuItem.isSelected())
    {
      return menuItem.zoom / 100f;
    }
  }
  throw new IllegalStateException("no zoom menu item is selected");
}

代码示例来源:origin: apache/pdfbox

/**
 * Set the zoom selection.
 *
 * @param zoomValue, e.g. 1, 0.25, 4.
 * @throws IllegalArgumentException if the parameter doesn't belong to a zoom menu item.
 */
public void changeZoomSelection(float zoomValue)
{
  String selection = (int)(zoomValue*100) +"%";
  for (Component comp : menu.getMenuComponents())
  {
    JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) comp;
    if (menuItem.getText().equals(selection))
    {
      menuItem.setSelected(true);
      return;
    }
  }
  throw new IllegalArgumentException("no zoom menu item found for: " + selection);
}

代码示例来源:origin: magefree/mage

public static void changePopupMenuFont(JPopupMenu popupMenu) {
  for (Component comp : popupMenu.getComponents()) {
    if (comp instanceof JMenuItem) {
      comp.setFont(GUISizeHelper.menuFont);
      if (comp instanceof JMenu) {
        comp.setFont(GUISizeHelper.menuFont);
        for (Component subComp : ((JMenu) comp).getMenuComponents()) {
          subComp.setFont(GUISizeHelper.menuFont);
        }
      }
    }
  }
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

private static Component[] childrenOf(Container popup) {
  if (popup instanceof JMenu)
    return ((JMenu) popup).getMenuComponents();
  return popup.getComponents();
}

代码示例来源:origin: org.orbisgis/orbisgis-view

/**
 * Extract sub elements that should contains actions.
 * @param container
 * @return
 */
private Component[] getSubElements(Container container) {
    if(container instanceof JMenu) {
        return ((JMenu)container).getMenuComponents();
    } else {
        return container.getComponents();
    }
}
private void feedMap(Container container, Map<String,Container> subContainers,Map<String,ButtonGroup> buttonGroups) {

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

/**
 * Extract sub elements that should contains actions.
 * @param container
 * @return
 */
private Component[] getSubElements(Container container) {
    if(container instanceof JMenu) {
        return ((JMenu)container).getMenuComponents();
    } else {
        return container.getComponents();
    }
}
private void feedMap(Container container, Map<String,Container> subContainers,Map<String,ButtonGroup> buttonGroups) {

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

/**
 * Aligns sub items in a menu.
 * 
 * @param menu the menu to align
 */
public static void alignMenu( JMenu menu) {
  alignComponents( menu.getMenuComponents());
}

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

/**
 * Returns an {@link Iterator} which traverses the JMenu one component at a time.
 *
 * @param self a JMenu
 * @return an Iterator for a JMenu
 * @since 1.6.4
 */
public static Iterator/*<MenuElement>*/ iterator(JMenu self) {
  return DefaultGroovyMethods.iterator(self.getMenuComponents());
}

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

/**
 * Returns an {@link java.util.Iterator} which traverses the JMenu one component at a time.
 *
 * @param self a JMenu
 * @return an Iterator for a JMenu
 * @since 1.6.4
 */
public static Iterator/*<MenuElement>*/ iterator(JMenu self) {
  return DefaultGroovyMethods.iterator(self.getMenuComponents());
}

代码示例来源:origin: GoldenGnu/jeveassets

private void showTableHeaderPopupMenu(final MouseEvent e) {
  JPopupMenu jTableHeaderPopupMenu = new JPopupMenu();
  JMenu columnMenu = tableMenu.getColumnMenu();
  if (columnMenu != null) {
    for (Component component : columnMenu.getMenuComponents()) { //Clone!
      jTableHeaderPopupMenu.add(component);
    }
  }
  jTableHeaderPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}

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

/**
 * Returns an {@link java.util.Iterator} which traverses the JMenu one component at a time.
 *
 * @param self a JMenu
 * @return an Iterator for a JMenu
 * @since 1.6.4
 */
public static Iterator/*<MenuElement>*/ iterator(JMenu self) {
  return DefaultGroovyMethods.iterator(self.getMenuComponents());
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

private void enableMenu(final JMenu menu) {
 menu.setEnabled(true);
 for (final Component c : menu.getMenuComponents()) {
  if (c instanceof JMenu) {
   enableMenu((JMenu) c);
  } else if (c instanceof JMenuItem) {
   ((JMenuItem) c).setEnabled(true);
  }
 }
}

代码示例来源:origin: org.zaproxy/zap

private void addAllMenuItems(List<KeyboardShortcut> kss, JMenu menu, boolean reset) {
  for (Component c: menu.getMenuComponents()) {
    if (c instanceof ZapMenuItem) {
      kss.add(menuToShortcut((ZapMenuItem)c, reset));
      
    } else if (c instanceof JMenu) {
      addAllMenuItems(kss, (JMenu)c, reset);
      
    } else if (c instanceof JMenuItem) {
      JMenuItem menuItem = (JMenuItem) c;
      logger.debug("Unable to set accelerators on menu " + menuItem.getText());
      
    }
  }
}

代码示例来源:origin: nroduit/Weasis

private JPopupMenu getLayoutPopupMenuButton(DropDownButton dropDownButton) {
  ActionState layout = eventManager.getAction(ActionW.LAYOUT);
  JPopupMenu popupMouseButtons = new JPopupMenu();
  if (layout instanceof ComboItemListener) {
    JMenu menu = ((ComboItemListener) layout).createUnregisteredRadioMenu("layout"); //$NON-NLS-1$
    popupMouseButtons.setInvoker(dropDownButton);
    Component[] cps = menu.getMenuComponents();
    for (int i = 0; i < cps.length; i++) {
      popupMouseButtons.add(cps[i]);
    }
  }
  return popupMouseButtons;
}

代码示例来源:origin: org.zaproxy/zap

private void initAllMenuItems(JMenu menu) {
  for (Component c: menu.getMenuComponents()) {
    if (c instanceof ZapMenuItem) {
      this.registerMenuItem((ZapMenuItem)c);
      
    } else if (c instanceof JMenu) {
      initAllMenuItems((JMenu)c);
      
    } else if (c instanceof JMenuItem) {
      JMenuItem menuItem = (JMenuItem) c;
      logger.debug("Unable to set accelerators on menu " + menuItem.getText());
    }
  }
}

代码示例来源:origin: caprica/vlcj-player

@Override
  protected void onPrepareMenu(JMenu menu) {
    String audioDeviceId = application().mediaPlayerComponent().getMediaPlayer().getAudioOutputDevice();
    for (Component c : menu.getMenuComponents()) {
      JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) c;
      AudioDevice audioDevice = (AudioDevice) menuItem.getClientProperty(KEY_AUDIO_DEVICE);
      if (audioDevice.getDeviceId().equals(audioDeviceId)) {
        menuItem.setSelected(true);
        break;
      }
    }
  }
}

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

public void removeFromWindowMenu(EditWindow window) {
  for (Component c : getRobocodeEditorMenuBar().getWindowMenu().getMenuComponents()) {
    if (c instanceof WindowMenuItem) {
      WindowMenuItem item = (WindowMenuItem) c;
      if (item.getEditWindow() == window) {
        getRobocodeEditorMenuBar().getWindowMenu().remove(item);
        getRobocodeEditorMenuBar().getMoreWindowsDialog().removeWindowItem(item);
        break;
      }
    }
  }
}

相关文章