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;
   }