ui/src/main/java/ucar/nc2/ui/util/SwingUtils.java
public static <T extends JComponent> List<T> getDescendantsOfType(
         Class<T> clazz, Container container, boolean nested) {
      List<T> tList = new ArrayList<T>();
      for (Component component : container.getComponents()) {
         if (clazz.isAssignableFrom(component.getClass())) {
            tList.add(clazz.cast(component));
         }
         if (nested || !clazz.isAssignableFrom(component.getClass())) {
            tList.addAll(SwingUtils.<T>getDescendantsOfType(clazz,
                  (Container) component, nested));
         }
      }
      return tList;
   }
public static <T extends JComponent> List<T> getDescendantsOfType(
         Class<T> clazz, Container container, boolean nested) {
      List<T> tList = new ArrayList<T>();
      for (Component component : container.getComponents()) {
         if (clazz.isAssignableFrom(component.getClass())) {
            tList.add(clazz.cast(component));
         }
         if (nested || !clazz.isAssignableFrom(component.getClass())) {
            tList.addAll(SwingUtils.<T>getDescendantsOfType(clazz,
                  (Container) component, nested));
         }
      }
      return tList;
   }
public static < T extends JComponent > List < T > getDescendantsOfType ( Class < T > clazz , Container container , boolean nested ) { List < T > tList = new ArrayList < T > ( ) ; for ( Component component : container . getComponents ( ) ) { if ( clazz . isAssignableFrom ( component . getClass ( ) ) ) { tList . add ( clazz . cast ( component ) ) ; } if ( nested || ! clazz . isAssignableFrom ( component . getClass ( ) ) ) { tList . addAll ( SwingUtils . < T > getDescendantsOfType ( clazz , ( Container ) component , nested ) ) ; } } return tList ; }
Convenience method for searching below <code>container</code> in the
component hierarchy and return nested components that are instances of
class <code>clazz</code> it finds. Returns an empty list if no such
components exist in the container.
<P>
Invoking this method with a class parameter of JComponent.class
will return all nested components.

@param clazz the class of components whose instances are to be found.
@param container the container at which to begin the search
@param nested true to list components nested within another listed
component, false otherwise
@return the List of components
Convenience method for searching below <code > container< / code > in the component hierarchy and return nested components that are instances of class <code > clazz< / code > it finds . Returns an empty list if no such components exist in the container . <P > Invoking this method with a class parameter of JComponent . class will return all nested components .