public static Container getAncestorNamed(final String name, final Component component) {
   Component ancestor = null;
   if (component != null && name != null) {
     for (ancestor = Utilities.getNotWindowParent(component);
         !((ancestor == null) || name.equals(ancestor.getName()));
         ancestor = Utilities.getNotWindowParent(ancestor)) ;
   }
   return (Container) ancestor;
 }
 private static Component getWindowOrAppletAncestor(final Component component) {
   Component result = component;
   while (result != null && !(result instanceof Window || result instanceof Applet)) {
     result = Utilities.getNotWindowParent(result);
   }
   return result;
 }
  public static boolean isDescendingFrom(final Component child, final Component parent) {
    if (parent == child) {
      return true;
    }

    for (Component ancestor = Utilities.getNotWindowParent(child);
        ancestor != null;
        ancestor = Utilities.getNotWindowParent(ancestor)) {

      if (ancestor == parent) {
        return true;
      }
    }

    return false;
  }
 private static void translateRelatedPoint(
     final Point point, final Component c, final int direction, final boolean stopAtRootPane) {
   Component currentComponent = c;
   while ((currentComponent != null)
       && (!stopAtRootPane || stopAtRootPane && !(currentComponent instanceof JRootPane))) {
     Point componentLocation = currentComponent.getLocation();
     point.x += direction * componentLocation.x;
     point.y += direction * componentLocation.y;
     currentComponent = Utilities.getNotWindowParent(currentComponent);
   }
 }
 public static void paintComponent(
     final Graphics graphics,
     final Component component,
     final Container container,
     final int x,
     final int y,
     final int width,
     final int height) {
   Container auxContainer = Utilities.getNotWindowParent(component);
   if (auxContainer instanceof CellRendererPane) {
     if (Utilities.getNotWindowParent(auxContainer) != container) {
       container.add(auxContainer);
     }
   } else {
     auxContainer = new CellRendererPane();
     container.add(auxContainer);
   }
   ((CellRendererPane) auxContainer)
       .paintComponent(graphics, component, container, x, y, width, height, false);
 }