java.awt.Container#getComponents ( )源码实例Demo

下面列出了java.awt.Container#getComponents ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Java8CN   文件: SortingFocusTraversalPolicy.java
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
源代码3 项目: jdk8u-jdk   文件: XDataViewer.java
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
源代码4 项目: ccu-historian   文件: OverlayLayout.java
/**
 * Calculates the preferred size dimensions for the specified
 * container, given the components it contains.
 *
 * @param parent the container to be laid out
 * @return the preferred size computed for the parent.
 * @see #minimumLayoutSize
 */
public Dimension preferredLayoutSize(final Container parent) {
    synchronized (parent.getTreeLock()) {
        final Insets ins = parent.getInsets();
        final Component[] comps = parent.getComponents();
        int height = 0;
        int width = 0;
        for (int i = 0; i < comps.length; i++) {
            if ((comps[i].isVisible() == false) && this.ignoreInvisible) {
                continue;
            }

            final Dimension pref = comps[i].getPreferredSize();
            if (pref.height > height) {
                height = pref.height;
            }
            if (pref.width > width) {
                width = pref.width;
            }
        }
        return new Dimension(width + ins.left + ins.right,
            height + ins.top + ins.bottom);
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: XDataViewer.java
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
源代码7 项目: netbeans   文件: HorizontalLayout.java
public Dimension minimumLayoutSize(final Container parent) {
    final Insets insets = parent.getInsets();
    final Dimension d = new Dimension(insets.left + insets.right,
                                      insets.top + insets.bottom);
    int maxHeight = 0;
    int visibleCount = 0;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible() && !(comp instanceof Box.Filler)) {
            final Dimension size = comp.getPreferredSize();
            maxHeight = Math.max(maxHeight, size.height);
            d.width += size.width;
            visibleCount++;
        }
    }

    d.width += (visibleCount - 1) * hGap;
    d.height += maxHeight;

    return d;
}
 
源代码8 项目: visualvm   文件: HorizontalLayout.java
public Dimension preferredLayoutSize(final Container parent) {
    final Insets insets = parent.getInsets();
    final Dimension d = new Dimension(insets.left + insets.right,
                                      insets.top + insets.bottom);
    int maxHeight = 0;
    int visibleCount = 0;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible()) {
            final Dimension size = comp.getPreferredSize();
            maxHeight = Math.max(maxHeight, size.height);
            d.width += size.width;
            visibleCount++;
        }
    }

    d.width += (visibleCount - 1) * hGap;
    d.height += maxHeight;

    return d;
}
 
源代码9 项目: jdk8u-dev-jdk   文件: XDataViewer.java
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
源代码10 项目: openjdk-jdk8u   文件: TextComponentPrintable.java
/**
 * Adds all {@code JEditorPanes} under {@code container} tagged by {@code
 * FrameEditorPaneTag} to the {@code list}. It adds only top
 * level {@code JEditorPanes}.  For instance if there is a frame
 * inside the frame it will return the top frame only.
 *
 * @param c the container to find all frames under
 * @param list {@code List} to append the results too
 */
private static void getFrames(final Container container, List<JEditorPane> list) {
    for (Component c : container.getComponents()) {
        if (c instanceof FrameEditorPaneTag
            && c instanceof JEditorPane ) { //it should be always JEditorPane
            list.add((JEditorPane) c);
        } else {
            if (c instanceof Container) {
                getFrames((Container) c, list);
            }
        }
    }
}
 
源代码11 项目: stendhal   文件: FreePlacementLayout.java
@Override
public void layoutContainer(Container parent) {
	Insets insets = parent.getInsets();
	int maxX = parent.getWidth() - insets.right;
	int maxY = parent.getHeight() - insets.bottom;
	for (Component c : parent.getComponents()) {
		int x = MathHelper.clamp(c.getX(), insets.top, maxX - c.getWidth());
		int y = MathHelper.clamp(c.getY(), insets.left, maxY - c.getHeight());
		c.setLocation(x, y);
	}
}
 
源代码12 项目: netbeans   文件: Actions.java
static void prepareMenuBridgeItemsInContainer(Container c) {
    Component[] comps = c.getComponents();

    for (int i = 0; i < comps.length; i++) {
        if (comps[i] instanceof JComponent) {
            JComponent cop = (JComponent) comps[i];
            MenuBridge bridge = (MenuBridge) cop.getClientProperty("menubridgeresizehack");

            if (bridge != null) {
                bridge.updateState(null);
            }
        }
    }
}
 
源代码13 项目: openjdk-8-source   文件: MetalworksPrefs.java
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}
 
源代码14 项目: jdk8u_jdk   文件: ColorChooserPanel.java
private static void setEnabled(Container container, boolean enabled) {
    for (Component component : container.getComponents()) {
        component.setEnabled(enabled);
        if (component instanceof Container) {
            setEnabled((Container) component, enabled);
        }
    }
}
 
源代码15 项目: mzmine3   文件: BaselineCorrectorSetupDialog.java
public static List<Component> getAllComponents(final Container c) {
  Component[] comps = c.getComponents();
  List<Component> compList = new ArrayList<Component>();
  for (Component comp : comps) {
    compList.add(comp);
    if (comp instanceof Container) {
      compList.addAll(getAllComponents((Container) comp));
    }
  }
  return compList;
}
 
源代码16 项目: pumpernickel   文件: DescendantListener.java
private void processAddition(Component c) {
	if (components.add(c)) {
		register(c);
		if (c instanceof Container) {
			Container container = (Container) c;
			container.addContainerListener(containerListener);
			for (Component child : container.getComponents()) {
				processAddition(child);
			}
		}
	}
}
 
源代码17 项目: jdk8u-dev-jdk   文件: TextComponentPrintable.java
/**
 * Adds all {@code JEditorPanes} under {@code container} tagged by {@code
 * FrameEditorPaneTag} to the {@code list}. It adds only top
 * level {@code JEditorPanes}.  For instance if there is a frame
 * inside the frame it will return the top frame only.
 *
 * @param c the container to find all frames under
 * @param list {@code List} to append the results too
 */
private static void getFrames(final Container container, List<JEditorPane> list) {
    for (Component c : container.getComponents()) {
        if (c instanceof FrameEditorPaneTag
            && c instanceof JEditorPane ) { //it should be always JEditorPane
            list.add((JEditorPane) c);
        } else {
            if (c instanceof Container) {
                getFrames((Container) c, list);
            }
        }
    }
}
 
源代码18 项目: openjdk-8   文件: Test6559154.java
private static void setEnabledRecursive(Container container, boolean enabled) {
    for (Component component : container.getComponents()) {
        component.setEnabled(enabled);
        if (component instanceof Container) {
            setEnabledRecursive((Container) component, enabled);
        }
    }
}
 
源代码19 项目: dragonwell8_jdk   文件: Test6559154.java
private static void setEnabledRecursive(Container container, boolean enabled) {
    for (Component component : container.getComponents()) {
        component.setEnabled(enabled);
        if (component instanceof Container) {
            setEnabledRecursive((Container) component, enabled);
        }
    }
}
 
源代码20 项目: openjdk-8   文件: MetalworksPrefs.java
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}