Sam
Sam

Reputation: 2782

JDialog does not open to it's set size?

Why when I launch my JDialog it pops up in a shrunken manner! I would have to resize it to see its contents and some of the contents like the labels don't show at all! Is there any settings that I should do?

I don't know whether you guy saw my comment under Andrew's solution. I just wanted to say that the pack() method solved the issue of jDialog showing in a shrunken way, however, I still have this problem that some of my controllers within this jDialog either don't show at all or shown in a randomly resized way. If you could also provide a remedy for this situation I would be very much thankful!

jDialog_DSCredentials = new javax.swing.JDialog();

jDialog_DSCredentials.setTitle(resourceMap.getString("jDialog_DSCredentials.title")); // NOI18N

jDialog_DSCredentials.setLocationByPlatform(true);

jDialog_DSCredentials.setName("jDialog_DSCredentials"); // NOI18N

jDialog_DSCredentials.getContentPane().setLayout(new java.awt.CardLayout());

// Code of sub-components and layout - not shown here  (I can send these if nec.)

and here is how it's called from an event method

jDialog_DSCredentials.pack();
jDialog_DSCredentials.revalidate();        
jDialog_DSCredentials.setVisible(true);

Upvotes: 0

Views: 3881

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

To have a top-level component become the smallest size it needs to show the content, call:

dialog.pack();

Upvotes: 8

Related Questions