List of usage examples for javax.swing JMenu getMenuComponent
public Component getMenuComponent(int n)
n
. From source file:Main.java
/** Convenience method that recursively enables every JMenu and JMenuItem inside "menu". * @param menu - the menu to start the recursive search *//* w w w .java2s. c o m*/ public static void enableAll(JMenu menu) { for (int i = 0; i < menu.getMenuComponentCount(); i++) { Component x = menu.getMenuComponent(i); if (x instanceof JMenuItem) ((JMenuItem) x).setEnabled(true); else if (x instanceof JMenu) enableAll((JMenu) x); } }
From source file:Main.java
public final static int countCheckBoxMenuItem(JMenu menu) { int count = 0; for (int i = 0; i < menu.getMenuComponentCount(); i++) { Component c = menu.getMenuComponent(i); if (c instanceof JCheckBoxMenuItem) { count++;/* w w w .j a v a2 s.c o m*/ } } return count; }
From source file:Main.java
public final static int getMenuItemIndex(JMenu menu, String menuItemText) { int theIdx = -1; for (int i = 0; i < menu.getMenuComponentCount(); i++) { Component c = menu.getMenuComponent(i); if (c instanceof JMenuItem) { JMenuItem mi = (JMenuItem) c; if (mi.getText().equals(menuItemText)) { theIdx = i;//w w w . j a v a2 s. co m i = menu.getMenuComponentCount();// break } } } return theIdx; }
From source file:Main.java
public final static JMenuItem getMenuItem(JMenu menu, String menuItemText) { JMenuItem theItem = null;// w w w .j av a2s. co m int idx = getMenuItemIndex(menu, menuItemText); if (idx > -1) { theItem = (JMenuItem) menu.getMenuComponent(idx); } return theItem; }
From source file:MainClass.java
private void applyOrientation(Component c, ComponentOrientation o) { c.setComponentOrientation(o);//from ww w . j a va2 s .com if (c instanceof JMenu) { JMenu menu = (JMenu) c; int ncomponents = menu.getMenuComponentCount(); for (int i = 0; i < ncomponents; ++i) { applyOrientation(menu.getMenuComponent(i), o); } } else if (c instanceof Container) { Container container = (Container) c; int ncomponents = container.getComponentCount(); for (int i = 0; i < ncomponents; ++i) { applyOrientation(container.getComponent(i), o); } } }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT; menu.applyComponentOrientation(ori); bar.add(menu);/*www. j a v a 2 s . c o m*/ menu.add(new JMenuItem("Close")); menu.add(new JSeparator()); // SEPARATOR menu.add(new JMenuItem("Exit")); setJMenuBar(bar); add(new JLabel("A placeholder")); pack(); setSize(300, 300); setVisible(true); Component c = menu.getMenuComponent(1); }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void displayAllMetricsOfAGroup(JMenu menu) { JCheckBoxMenuItem item = null; String name = null;// w ww .j a va2 s . c o m for (int i = 0; i < menu.getMenuComponentCount(); i++) { if (menu.getMenuComponent(i) instanceof JCheckBoxMenuItem) { item = (JCheckBoxMenuItem) menu.getMenuComponent(i); name = item.getActionCommand(); if (!item.isSelected()) { item.setSelected(true); createPlotInWindow(name); } } } }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void removeAllMetricsOfAGroup(JMenu menu) { JCheckBoxMenuItem item = null; String name = null;/*from w w w . j a v a2 s .c o m*/ for (int i = 0; i < menu.getMenuComponentCount(); i++) { if (menu.getMenuComponent(i) instanceof JCheckBoxMenuItem) { item = (JCheckBoxMenuItem) menu.getMenuComponent(i); name = item.getActionCommand(); if (item.isSelected()) { item.setSelected(false); deletePlotInWindow(name); } } } }
From source file:no.java.ems.client.swing.EmsClient.java
private void removeIcons(final JMenu menu) { for (int index = 0; index < menu.getMenuComponentCount(); index++) { Component item = menu.getMenuComponent(index); if (item instanceof JMenu) { removeIcons((JMenu) item); }/*from w w w. ja va 2 s . co m*/ if (item instanceof JMenuItem) { ((JMenuItem) item).setIcon(null); } } }
From source file:org.eclipse.wb.internal.swing.model.component.exposed.SwingHierarchyProvider.java
@Override public Object[] getChildrenObjects(Object object) throws Exception { // javax.swing.JMenu if (object instanceof JMenu) { JMenu menu = (JMenu) object; int componentCount = menu.getMenuComponentCount(); Component[] menuComponents = new Component[componentCount]; for (int i = 0; i < componentCount; i++) { menuComponents[i] = menu.getMenuComponent(i); }/*w w w .ja v a2 s.c om*/ return menuComponents; } // generic java.awt.Container if (object instanceof Container) { Container container = (Container) object; return container.getComponents(); } // unknown return ArrayUtils.EMPTY_OBJECT_ARRAY; }