Hi,

This patch fixes the placement of heavyweight components in lightweight
containers.  I have an app that adds a Canvas to a JFrame; the canvas
was being drawn with the wrong offsets relative to the frame.  I've
committed this patch, which fixes the canvas's placement.

Tom

2005-08-31  Thomas Fitzsimmons  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/gtk/GtkComponentPeer.java (setBounds): Only
        add parent's x and y co-ordinates to translation if parent's
        parent is not a window.

Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.95
diff -u -r1.95 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java	25 Aug 2005 02:26:48 -0000	1.95
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java	31 Aug 2005 21:13:40 -0000
@@ -424,6 +424,7 @@
     int new_y = y;
 
     Component parent = awtComponent.getParent ();
+    Component next_parent;
 
     // Heavyweight components that are children of one or more
     // lightweight containers have to be handled specially.  Because
@@ -441,12 +442,22 @@
       {
 	lightweightChild = true;
 
+        next_parent = parent.getParent ();
+
 	i = ((Container) parent).getInsets ();
 
-	new_x += parent.getX () + i.left;
-	new_y += parent.getY () + i.top;
+        if (next_parent instanceof Window)
+          {
+            new_x += i.left;
+            new_y += i.top;
+          }
+        else
+          {
+            new_x += parent.getX () + i.left;
+            new_y += parent.getY () + i.top;
+          }
 
-	parent = parent.getParent ();
+	parent = next_parent;
       }
 
     // We only need to convert from Java to GTK coordinates if we're
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to