FlapWindow has wrong size

When I click on a minimized dockable button the flap window is correct. Close the flap window and resize the JFrame.
Open the flap window again and it has still the previous size,
which is not correct.
When you resize the JFrame whilst the flap window is open, the flap window is correctly resized

See attachment.

When I do this it works fine, there is only small moment when the window gets resized. But then I’m currently using Vista and Java 1.5…

What Java version is currently on your system? Do you perhaps use a special window manager like Beryl or Compiz?

Working on Linux with KDE and Java 1.6 update 10

Looks like the updateBounds() method is called to late.
The setVisible() is called before the updateBounds() has been called.
I put some debug in:

            SwingUtilities.convertPointToScreen( location, buttonPane );
            setLocation( location );
            
            System.out.println("size = " + size );
            setSize( size );
            
            validate();
        }
    }
    
   public void setVisible(boolean flag)
   {
      System.out.println("setVisible size = " + getSize() );
      super.setVisible(flag);
   }

Gives the following output:

setVisible size = java.awt.Dimension[width=0,height=0] // First visible(true)
size = java.awt.Dimension[width=594,height=158]

setVisible size = java.awt.Dimension[width=594,height=158] // visible(false)

setVisible size = java.awt.Dimension[width=594,height=158] // visible(true) after resize of JFrame. Width has been changed
size = java.awt.Dimension[width=451,height=158]

It works when I add the following code in FlapWindow:

   public void setVisible(boolean flag)
   {
      if (flag)
         updateBounds();
      
      super.setVisible(flag);
   }

That just means that the second size is somehow ignored?
I mean this one: “size = java.awt.Dimension[width=451,height=158]”.

Strange.

Well since your fix works I just copy it :-/

(Btw. That is not the first time these windows cause problem. I even had once the issue that the “setVisible( false )” command was just ignored. I suspect there were some race conditions but I could never prove it.)

Hmm, the fix is not correct.

Just open and close a flapwindow multiple times, the window gets bigger and bigger :o

The getDockableInsets() in updateBounds() returns each time something else:

insets java.awt.Insets[top=24,left=2,bottom=2,right=2]
insets java.awt.Insets[top=26,left=4,bottom=7,right=4]
insets java.awt.Insets[top=24,left=2,bottom=160,right=596]
insets java.awt.Insets[top=24,left=2,bottom=311,right=596]

What happens if you add a “validate” in “updateBounds”? At this location:

    	Dockable dockable = displayer == null ? null : displayer.getDockable();
        if( dockable != null ){
        	validate();  // <-- here```

Normally Containers do not get validated as long as they are invisible.

Well, you fixed the fix :smiley: