Mailing Lists: Apple Mailing Lists

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

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



Hi,

for several days now I struggle with the following, rather simple UI
requirement:

In a window, I must display a subpane depending on user selection. The
subpane contents varies depending on the specific subpane. I want the
window to grow to its pack()ed size after exchanging a subpane, but I
don't want it to shrink (except when explicitly resized by the user).

To see what I mean, check the Preferences dialog window in eclipse: When
a pane is bigger than the current window size, the window is
automatically enlarged, but when a smaller pane is selected, it does not
shrink.

I know (from earlier messages on this list) that I cannot set a minimum
size on a window (at least not one that actually works).

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. This
all does happen at an enough low speed so the user *does* notice what is
going on and sees a great flickering of the window.

My idea now is, if I could retrieve the size a call on pack() *would*
give the window, I could avoid having it shrink by just calculating that
value, exchange the subpane, and only if the dimensions are greater than
the current ones, I'd do a resize() to the larger size. But I see no way
to get at this "dimension it would have if pack() was called".

Do I have any other options? Can I call pack() somehow while redirecting
the actual window drawing to "/dev/null" (or offscreen bitmap) so that
the short, intermediate shrinked window state is never visibly drawn to
the screen?

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.