jdk/src/share/classes/java/awt/Component.java
changeset 9471 a0139be72f1d
parent 9050 26c2c1de1631
child 9658 5484189eeabb
--- a/jdk/src/share/classes/java/awt/Component.java	Sat Apr 16 22:45:08 2011 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java	Tue Apr 19 14:44:09 2011 +0400
@@ -2945,6 +2945,46 @@
     }
 
     /**
+     * Revalidates the component hierarchy up to the nearest validate root.
+     * <p>
+     * This method first invalidates the component hierarchy starting from this
+     * component up to the nearest validate root. Afterwards, the component
+     * hierarchy is validated starting from the nearest validate root.
+     * <p>
+     * This is a convenience method supposed to help application developers
+     * avoid looking for validate roots manually. Basically, it's equivalent to
+     * first calling the {@link #invalidate()} method on this component, and
+     * then calling the {@link #validate()} method on the nearest validate
+     * root.
+     *
+     * @see Container#isValidateRoot
+     * @since 1.7
+     */
+    public void revalidate() {
+        synchronized (getTreeLock()) {
+            invalidate();
+
+            Container root = getContainer();
+            if (root == null) {
+                // There's no parents. Just validate itself.
+                validate();
+            } else {
+                while (!root.isValidateRoot()) {
+                    if (root.getContainer() == null) {
+                        // If there's no validate roots, we'll validate the
+                        // topmost container
+                        break;
+                    }
+
+                    root = root.getContainer();
+                }
+
+                root.validate();
+            }
+        }
+    }
+
+    /**
      * Creates a graphics context for this component. This method will
      * return <code>null</code> if this component is currently not
      * displayable.