• Post Reply Bookmark Topic Watch Topic
  • New Topic

Window Update Problem If Window is Being Moved

 
Joshua Smith
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All-

I have a small Swing application that makes a couple of additional buttons visible if the application switches into a configuration state. The buttons are added to their parent JPanel when the JPanel is first instantiated, but they are only made visible when the application enters configuration mode. When the application enters configuration mode the visibility on the buttons is set to true, invalidate is called on their containing panel, pack and invalidate are called on the parent JFrame and the size of the window grows slightly to make room for the buttons.

I have two questions:

1) If I click the button to enter configuration mode and wait for the buttons to appear (this happens fairly quickly), there are no problems. But if I click the button to enter configuration mode and immediately grab the window by the title bar and move it around, the buttons never appear - even after I've let go of the window. It's as if moving the window interupts the calls to invalidate and pack that are needed for the window to resize correctly and for the buttons to appear.

Has anyone else encountered problems related to invalidate and or pack being hindered by moving windows around when it's supposed to be taking place?

2) After entering configuration mode the window grows slightly to allow for the additional buttons (assuming that I don't move the window and interupt that process). After leaving configuration mode the buttons are made invisible again and invalidate is called on the JPanel and pack and invalidate are called on the JFrame. Instead of shrinking the window back down to it's original size before the buttons were displayed, the buttons are simply hidden and the rest of the Swing components are now recentered in the larger JFrame.

How do I force the window to recalculate its sizing requirements so that it will return to it's pre-configuration mode size?

Thank you,
Joshua Smith
 
Joshua Smith
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to figure out number 2, but number 1 is still a problem.

Can anyone point me in the right direction?

Thanks,
Josh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!