KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > testbed > workbench > util > gui > Containers


1 package org.enhydra.barracuda.testbed.workbench.util.gui;
2
3 import java.awt.Container JavaDoc;
4 import java.awt.Component JavaDoc;
5
6
7 /**
8  * Container utilities
9  */

10 public class Containers {
11
12     /**
13      * This method finds the root container given a starting component
14      *
15      * @param comp
16      * @return the root Container or null if the Component argument is null
17      */

18     public static Container JavaDoc getRootContainer(Component JavaDoc comp) {
19         if (comp==null) return null;
20         return getRootContainer(comp.getParent());
21     }
22
23     /**
24      * This method finds the root container given a starting container
25      *
26      * @param cont The container in question
27      * @return the root Container or null if the Container argument is null
28      */

29     public static Container JavaDoc getRootContainer(Container JavaDoc cont) {
30
31         //eliminate the obvious
32
if (cont==null) return null;
33
34         Container JavaDoc parent = cont.getParent();
35         if (parent!=null) return getRootContainer(parent);
36         else return cont;
37     }
38
39 }
40
Popular Tags