Hi,

Can someone who is more up to speed with AWT please take a look at the
attached patch? While running some AWT code I got a ClassCastException
in this code and while I didn't quite understand the point of the code
(or why it failed), it looked to me as if the logic was wrong. It tries
to find the toplevel window, but if it doesn't find it, it still goes
ahead and casts the component to a window.

Thanks.

Regards,
Jeroen
Index: java/awt/DefaultKeyboardFocusManager.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/awt/DefaultKeyboardFocusManager.java,v
retrieving revision 1.13
diff -u -r1.13 DefaultKeyboardFocusManager.java
--- java/awt/DefaultKeyboardFocusManager.java   21 May 2005 07:06:38 -0000      
1.13
+++ java/awt/DefaultKeyboardFocusManager.java   29 Jun 2005 13:06:48 -0000
@@ -194,13 +194,15 @@
                    && !(parent instanceof Window))
               parent = parent.getParent ();
 
-            Window toplevel = parent == null ?
-              (Window) target : (Window) parent;
+            if (parent != null)
+              {
+                Window toplevel = (Window) parent;
 
-            Component focusOwner = getFocusOwner ();
-            if (focusOwner != null
-                && ! (focusOwner instanceof Window))
-              toplevel.setFocusOwner (focusOwner);
+                Component focusOwner = getFocusOwner ();
+                if (focusOwner != null
+                    && ! (focusOwner instanceof Window))
+                  toplevel.setFocusOwner (focusOwner);
+              }
           }
         else if (e.id == FocusEvent.FOCUS_LOST)
           {
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to