If you run the pack
command on the dialog (a function in the Window class) it will resize based on subcomponents. For your case you will have to rewrite without using the showMessageDialog()
to get the resize to work (so make the dialog first, add the text, pack, then show it)
Dialog b = new Dialog();
// add stuff
b.pack();
For my test code it worked perfectly to get the dialogs to be the right sizes
- Without
pack()
- With
pack()