This fixes the painting problem with JApplets. In most cases, the
components were being drawn on the Window rather than the actual applet.


2006-05-02  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/SwingUtilities.java
        (getRoot): Should return the Applet if it exists.
        Only return the Window if an Applet has not been
        encountered.

Index: javax/swing/SwingUtilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v
retrieving revision 1.48
diff -u -r1.48 SwingUtilities.java
--- javax/swing/SwingUtilities.java	13 Mar 2006 21:36:30 -0000	1.48
+++ javax/swing/SwingUtilities.java	2 May 2006 18:14:31 -0000
@@ -376,21 +376,20 @@
   public static Component getRoot(Component comp)
   {
     Applet app = null;
-    Window win = null;
-
+    
     while (comp != null)
       {
-        if (win == null && comp instanceof Window)
-          win = (Window) comp;
+        // A Window cannot be in an applet, so 
+        // the Window returned would be encountered
+        // after the applet.
+        if (app == null && comp instanceof Window)
+          return (Window) comp;
         else if (comp instanceof Applet)
           app = (Applet) comp;
         comp = comp.getParent();
       }
-
-    if (win != null)
-      return win;
-    else
-      return app;
+    
+    return app;
   }
 
   /**

Reply via email to