At 08:24 PM 3/14/2001 +0530, Bharat Dighe wrote:
>Hi All,
>
>Can we determine the packed size of a panel before making it visible? In
>other words, is there any api which will give me the size
>of a packed frame which contains a panel, before making the frame visible
>using show() or setVisible() methods?
>I have a list of panels which I need to add to a frame one below the
>other, but i have to set the frame size equal to the size of
>the largest panel.
>
>Thanks.
> - Bharat
You can call getPreferredSize() on each JPanel to get the size it
would be, if it were packed. Beware of a few things, though.
FlowLayout panels will prefer to put all their components on a single
row. This may result in something wider than you like.
A packed JFrame will always be bigger than its content pane, since all
JFrames have title bars. If you want room for the title bar (and the
menu bar, if you have that too), you'll have to factor in the sizes
for those, and enlarge the preferred size you get by the appropriate
amounts.
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing