JDialog Comes Shrinked On Creation
I'm developing a swing project in Netbeans. I've created a JFrame and added a modal JDialog instance in that JFrame to get credentials from user. Th开发者_C百科e JDialog instance is set visible in the JFrame's constructor. When it runs, the JDialog instance is shown before the JFrame, as expected, but the JDialog window comes resized to the tiniest possible dimension. User has to manually resize it each time to see that there is some textboxes to fill. I've tried setting preferredSize manually but it didn't work. How can I make it to come with the same size as it looks on the design view?
dialog.setSize(width, height)
should work.
Make sure that all the dialog's children have preferred sizes as well, and then call the pack()
method on the container.
精彩评论