Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Frame.setExtendedState() causes bounds to be reset?

 
Laird Nelson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Windows 2000 and JDK 1.4.1.
I've got a simple Frame that I'd like to make behave properly in between application invocations. For example, when the application exits, I save its bounds and extendedState in my Preferences tree.
I'm running into trouble with maximization. If, during startup, I do the following:
1. frame.pack(); // realize the frame
2. frame.setBounds(boundsFromPreferences);
3. frame.setExtendedState();
4. frame.setVisible(true);
...then as expected the frame will come up, say, maximized, if the user had maximized it before closing it the last time. So far so good.
But: if the user restores the frame, it does not return to the bounds set in (2) above. Instead, it seems to decrease in overall size by one or two pixels.
I'm suspecting that setExtendedState(), as called in (3) above, and which calls setState() in the Windows implementation of FramePeer.java, causes FramePeer.setState() to call something like reshape() or setBounds() to be called as well, which blows away the bounds that I set in (2) above.
Interestingly, this doesn't happen on minimization. If the user minimizes the application, exits (thus saving the extended state to Preferences), restarts, and restores the application, everything works properly.
Does anyone have anything to add on this? I've also noticed two methods in Frame.java--setMaximizedBounds() and getMaximizedBounds() which suggest that someone at Sun was beginning to work on this problem but never really got all the way through it.
Laird
 
Laird Nelson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, after some more research, I figured out what the behavior is. That doesn't necessarily make it right. To wit: does indeed set the bounds of a Frame--but only when it's visible, regardless of whether it's realized.
It seems like should behave like other GUI-rendering code, in that a call to or should be all that's necessary before doing size-related operations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!