Java JComponent Container getChildJComponents(Container container)

Here you can find the source of getChildJComponents(Container container)

Description

get Child J Components

License

Open Source License

Declaration

public static List getChildJComponents(Container container) 

Method Source Code

//package com.java2s;
/*/*  w  ww. ja v  a2s .  c om*/
 * Copyright 2001-2008 Aqris Software AS. All rights reserved.
 * 
 * This program is dual-licensed under both the Common Development
 * and Distribution License ("CDDL") and the GNU General Public
 * License ("GPL"). You may elect to use one or the other of these
 * licenses.
 */

import javax.swing.JComponent;

import java.awt.Component;
import java.awt.Container;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List getChildJComponents(Container container) {
        List result = new ArrayList();

        Component[] children = container.getComponents();

        for (int i = 0; i < children.length; i++) {
            if (children[i] instanceof JComponent) {
                result.add(children[i]);
                result.addAll(getChildJComponents((JComponent) children[i]));
            }
        }

        return result;
    }
}

Related

  1. getActiveRectangle(JComponent c)
  2. getAllJComponents(Container container, Collection collection)
  3. getAncestorOfType(JComponent component, Class type)
  4. getAncestorsOfClass(JComponent start, Class theClass)
  5. getBooleanClientProperty(JComponent c, Object property)
  6. getClipboard(JComponent c)
  7. getComponent(JComponent container, String name)
  8. getComponent(JComponent container, String name)
  9. getComponentByName(boolean enableDeepSearch, JComponent rootComponent, String name)