Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to make the length of Message Dialog follows the length of text

843807Feb 1 2010 — edited Feb 1 2010
Hi all.
I am making a Message Dialog From JOptionPane because i do not want to use some static methods of JOptionPane (JOptionPane.Show ...)
My source codes following :
public static void showMessageDialog(String message) {
		JOptionPane optionPane = new JOptionPane();
		JDialog dialog = optionPane.createDialog(null, "Message");
		optionPane.setMessage(message);
		optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
		JButton btnOk = new JButton("OK");
		optionPane.setOptions(new Object[] { btnOk });
		dialog.setVisible(true);
}
It runs well but having a problem. When message is a long text --> JDialog can not show all text, dialog's length does not resize automatically following message's length.
Have a the way to make it ? How to solve ?

Thanks in advance !
Diego

Edited by: ThuCT on Feb 1, 2010 3:28 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2010
Added on Feb 1 2010
5 comments
343 views