Hi,

I have found a nasty problem, that is visible when using the pack()
method on frames. The problem is that before a window is opened, the
insets of the window are (0,0,0,0) because the window decorations are
not yet known about (I guess). However, after a window is up, the insets
are correctly set to some sane value like (23, 5, 5, 5). The problem is
that pack() sets the window size to the preferred size of the contained
components and is usually called _before_ a window is opened. This
messes up the layout and pack() has not the desired effect. I hope my
explanations are not too confusing ;-) If you want to see what I mean,
start the Swing example and open one of the dialogs by pushing the
buttons. Do this before and after applying my patch.

The attached patch fixes this by resizing the window by the insets of
the window decorations immediatly after the window is opened. Here this
works pretty good, but since I'm not very familiar with the GTK code I
think I ask better if I should commit this as it is, or if this can be
made better.

2005-04-20  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/gtk/GtkWindowPeer.java
        (postWindowEvent): Resize window after opening to take the
        window decoration insets into account.

/Roman

Index: gnu/java/awt/peer/gtk/GtkWindowPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java,v
retrieving revision 1.34
diff -u -r1.34 GtkWindowPeer.java
--- gnu/java/awt/peer/gtk/GtkWindowPeer.java	22 Feb 2005 07:40:43 -0000	1.34
+++ gnu/java/awt/peer/gtk/GtkWindowPeer.java	20 Apr 2005 19:58:34 -0000
@@ -187,6 +187,9 @@
   {
     if (id == WindowEvent.WINDOW_OPENED)
       {
+        setBounds (awtComponent.getX(), awtComponent.getY(),
+                   getWidth() + insets.left + insets.right,
+                 getHeight() + insets.top + insets.bottom);
 	// Post a WINDOW_OPENED event the first time this window is shown.
 	if (!hasBeenShown)
 	  {
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to