ui/src/main/java/ucar/nc2/ui/util/SwingUtils.java
public static Map<JComponent, List<JComponent>> getComponentMap(
         JComponent container, boolean nested) {
      HashMap<JComponent, List<JComponent>> retVal =
            new HashMap<JComponent, List<JComponent>>();
      for (JComponent component : getDescendantsOfType(JComponent.class,
            container, false)) {
         if (!retVal.containsKey(container)) {
            retVal.put(container,
                  new ArrayList<JComponent>());
         }
         retVal.get(container).add(component);
         if (nested) {
            retVal.putAll(getComponentMap(component, nested));
         }
      }
      return retVal;
   }
public static Map<JComponent, List<JComponent>> getComponentMap(
         JComponent container, boolean nested) {
      HashMap<JComponent, List<JComponent>> retVal =
            new HashMap<JComponent, List<JComponent>>();
      for (JComponent component : getDescendantsOfType(JComponent.class,
            container, false)) {
         if (!retVal.containsKey(container)) {
            retVal.put(container,
                  new ArrayList<JComponent>());
         }
         retVal.get(container).add(component);
         if (nested) {
            retVal.putAll(getComponentMap(component, nested));
         }
      }
      return retVal;
   }
public static Map < JComponent , List < JComponent > > getComponentMap ( JComponent container , boolean nested ) { HashMap < JComponent , List < JComponent > > retVal = new HashMap < JComponent , List < JComponent > > ( ) ; for ( JComponent component : getDescendantsOfType ( JComponent . class , container , false ) ) { if ( ! retVal . containsKey ( container ) ) { retVal . put ( container , new ArrayList < JComponent > ( ) ) ; } retVal . get ( container ) . add ( component ) ; if ( nested ) { retVal . putAll ( getComponentMap ( component , nested ) ) ; } } return retVal ; }
Convenience method for mapping a container in the hierarchy to its
contained components.  The keys are the containers, and the values
are lists of contained components.
<P>
Implementation note:  The returned value is a HashMap and the values
are of type ArrayList.  This is subject to change, so callers should
code against the interfaces Map and List.

@param container The JComponent to be mapped
@param nested true to drill down to nested containers, false otherwise
@return the Map of the UI
Convenience method for mapping a container in the hierarchy to its contained components . The keys are the containers and the values are lists of contained components . <P > Implementation note : The returned value is a HashMap and the values are of type ArrayList . This is subject to change so callers should code against the interfaces Map and List .