jdk/test/javax/swing/regtesthelpers/Util.java
changeset 10691 50cda9bfed7e
parent 8757 2afba8862932
child 11096 a39b7342177f
--- a/jdk/test/javax/swing/regtesthelpers/Util.java	Wed Oct 05 18:21:23 2011 +0400
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java	Tue Oct 11 15:22:40 2011 +0400
@@ -116,4 +116,28 @@
 
         System.out.println("Got OOME");
     }
+
+    /**
+     * Find a sub component by class name.
+     * Always run this method on the EDT thread
+     */
+    public static Component findSubComponent(Component parent, String className) {
+        String parentClassName = parent.getClass().getName();
+
+        if (parentClassName.contains(className)) {
+            return parent;
+        }
+
+        if (parent instanceof Container) {
+            for (Component child : ((Container) parent).getComponents()) {
+                Component subComponent = findSubComponent(child, className);
+
+                if (subComponent != null) {
+                    return subComponent;
+                }
+            }
+        }
+
+        return null;
+    }
 }