Some examples of using the Joptionpane class pop-up message box in Java

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.