Dialog(Dialog owner)
Constructs an initially invisible, non-modal Dialog with an empty title and the specified owner dialog.
Dialog(Dialog owner, String title)
Constructs an initially invisible, non-modal Dialog with the specified owner dialog and title.
Dialog(Dialog owner, String title, boolean modal)
Constructs an initially invisible Dialog with the specified owner dialog, title, and modality.
Dialog(Frame owner)
Constructs an initially invisible, non-modal Dialog with an empty title and the specified owner frame.
Dialog(Frame owner, boolean modal)
Constructs an initially invisible Dialog with an empty title, the specified owner frame and modality.
Dialog(Frame owner, String title)
Constructs an initially invisible, non-modal Dialog with the specified owner frame and title.
Dialog(Frame owner, String title, boolean modal)
Constructs an initially invisible Dialog with the specified owner frame, title, and modality.
Constructs an initially invisible, non-modal Dialog with an empty title and the specified owner dialog.
Dialog(Dialog owner, String title)
Constructs an initially invisible, non-modal Dialog with the specified owner dialog and title.
Dialog(Dialog owner, String title, boolean modal)
Constructs an initially invisible Dialog with the specified owner dialog, title, and modality.
Dialog(Frame owner)
Constructs an initially invisible, non-modal Dialog with an empty title and the specified owner frame.
Dialog(Frame owner, boolean modal)
Constructs an initially invisible Dialog with an empty title, the specified owner frame and modality.
Dialog(Frame owner, String title)
Constructs an initially invisible, non-modal Dialog with the specified owner frame and title.
Dialog(Frame owner, String title, boolean modal)
Constructs an initially invisible Dialog with the specified owner frame, title, and modality.
Dialog(Dialog owner)
Dialog(Dialog owner,String title)
Dialog(Dialog Owner,String title,boolean modal)
Dialog(Frame owner)
Dialog(Frame owner,boolean modal)
Dialog(Frame owner,String title)
Dialog(Frame owner,String title,boolean modal)
看看,一可以用哪一个?
当然不行。
用 null 试试。
Displays a modal dialog with one button, which is labeled "OK" (or the localized equivalent). You can easily specify the message, icon, and title that the dialog displays. Here are some examples of using showMessageDialog:
//default title and icon
JOptionPane.showMessageDialog(frame,
"Eggs aren't supposed to be green.");
//custom title, warning icon
JOptionPane.showMessageDialog(frame,
"Eggs aren't supposed to be green.",
"Inane warning",
JOptionPane.WARNING_MESSAGE);
//custom title, error icon
JOptionPane.showMessageDialog(frame,
"Eggs aren't supposed to be green.",
"Inane error",
JOptionPane.ERROR_MESSAGE);
//custom title, no icon
JOptionPane.showMessageDialog(frame,
"Eggs aren't supposed to be green.",
"A plain message",
JOptionPane.PLAIN_MESSAGE);
//custom title, custom icon
JOptionPane.showMessageDialog(frame,
"Eggs aren't supposed to be green.",
"Inane custom dialog",
JOptionPane.INFORMATION_MESSAGE,
icon);