Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get the size of a window "it would have if calling pack() on it"



Five minutes after sending my question, I happened to stumble on the
(now looking quite obvious - sigh...) solution by inspecting the source
code of "pack()". My problem was:

>So I am currently doing the following:
>
>1. I save the current window size.
>2. I exchange the subpane, then call pack() on the window.
>3. If the size of the window now is smaller than the saved window size,
>I do a resize() the the saved extents.
>
>In effect, this works, but is visually ugly as hell: In response to the
>call to pack(), the window momentarily is displayed in its smaller state
>(if the new subpane is smaller than the previous one), and then
>immediately grown to its former size in response to step 3 above.

The solution is simple:

In step 2, do not call pack(), but getPreferredSize(). Then proceed with
3, setting the maximum of the saved window dimension and the one gotten
from step 2.

(My apologies for the unnecessary bandwidth.)

Regards, Christian.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.