Source code and the following
Example:
1, an error dialog box appears:
Joptionpane.showmessagedialog (NULL, "This is the content", "This is the title", Joptionpane.error_message);
2, display an information panel with the options "yes/no":
Joptionpane.showconfirmdialog (NULL, "This is the content", "This is the title", Joptionpane.yes_no_option);
3, a warning dialog box is displayed with the options OK, CANCEL:
object[] options = {"OK", "Cancel"};
Joptionpane.showoptiondialog (NULL, "This is the content", "This is the title", Joptionpane.default_option,
Joptionpane.warning_message,null, Options, options[0]);
4, displays a dialog box that asks the user to type String:
String Inputvalue = Joptionpane.showinputdialog ("Please enter your content:");
Joptionpane.showinputdialog ("Please enter your content:");
5, displays a dialog box that asks the user to select a String:
Object[] PossibleValues = {"First", "Second", "third"};
Object SelectedValue = Joptionpane.showinputdialog (NULL, "This is the content", "This is the title",
Joptionpane.information_message, NULL, PossibleValues, possiblevalues[0]);
6, this is a simple message box:
Joptionpane.showmessagedialog (NULL, "This is a simple message box");
7, this is a dialog box for the user to enter information:
Joptionpane.showinputdialog (NULL, "This is a dialog box for the user to enter information");
8, this is a simple warning box:
Joptionpane.showmessagedialog (NULL, "This is the content", "This is the title", Joptionpane.warning_message);
Some examples of using the Joptionpane class pop-up message box in Java