Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: JDialog sizes under OS X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JDialog sizes under OS X



Your problem is the line,

setSize(jPanel.getPreferredSize());

Where did you ever come up with that construct? The JDialog needs to be larger than the JPanel in order to account for the window "decoration" (title bar, etc.).

The correct thing to do is to call pack() on the JDialog. This will ask the JPanel for it's preferred size and resize the Dialog so everything fits.

At 12:02 PM -0700 4/27/01, Christian Schaller wrote:
Hi. I'm wondering if anyone else has had this problem and what the
solution might be. Under OS X, my JDialogs invariably come out the wrong
size vertically -- they're too short, and interface elements at the bottom
of the window are always chopped off.

For example, in an About dialog that extends JDialog, I'm putting a JLabel
(with an image icon) and a JButton into a JPanel, then adding the JPanel
to the content pane of the JDialog. Then I'm setting the size to the
preferred size of the JPanel:

getContentPane().add(jPanel);
setSize(jPanel.getPreferredSize());

It doesn't seem to matter what Layout I use for the jPanel. If I use a
BorderLayout and put the JLabel North and the JButton Center or if I use a
BoxLayout, it's still the same thing: a window truncated at the bottom.

It also doesn't seem to matter whether I use the Aqua look and feel or the
Metal look and feel.

Meanwhile, windows that are extensions of JFrame don't have this problem.

Can someone suggest a solution, please?

Thanks,

Chris Schaller

--
Bill Tschumy
Otherwise -- Austin, TX
email@hidden


References: 
 >JDialog sizes under OS X (From: Christian Schaller <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.