Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
  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;
  }
Ejemplo n.º 4
0
 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);
   }
 }
Ejemplo n.º 5
0
 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);
 }