4 common dialog boxes for Joptionpane

Source: Internet
Author: User

The Joptionpane class has 4 static methods for displaying dialog boxes :
Message, options, Confirmation, Input dialog box

showMessageDialog://显示一条消息并等待用户OKshowConfirmDialog://显示一条消息并等待用户确认//显示一条消息并获得一组选项的选择showInputDialog:  //显示一条消息并获得输入的一行文本

The message dialog box has the following methods:

Parentcomponet//Parent ComponentMassage//Message Object displayed in dialog box (string, icon, component or array)Title//dialog box titleMessageType//message type, decision icon, value: Error_message,information_message,warning_message,question_message,plain_message oneIcon//icon to replace the standard iconImport Javax.swing.JOptionPane; Public classMessage { Public Static void Main(string[] args) {Joptionpane.showmessagedialog (NULL,"This is message!","Messagedialog", joptionpane.question_message);//joptionpane.showmessagedialog (NULL, "This is message!", "Messagedialog", joptionpane.information_message);}}//Message type decision icon


The Options dialog box has the following methods:

//参数parentComponet   //父组件massage          //显示在对话框中的消息对象(字符串String,图标Icon,组件或者数组)title            //对话框标题messageType      //消息类型,决定图标,取值:ERROR_MESSAGE,INFORMATION_MESSAGE,WARNING_MESSAGE,QUESTION_MESSAGE,PLAIN_MESSAGE之一optionType      //取值DEFAULT_OPTION,YES_NO_OPTION,YES_NO_CANCEL_OPTION,OK_CANCEL_OPTIONicon            //用于替代标准图标的图标otptions        // 一组选项,可以是字符串,图标,组件

OK dialog box:

//ParametersParentcomponet//Parent ComponentMassage//Message Object displayed in dialog box (string, icon, component or array)Title//dialog box titleMessageType//message type, decision icon, value: Error_message,information_message,warning_message,question_message,plain_message oneOptiontype//value default_option,yes_no_option,yes_no_cancel_option,ok_cancel_optionIcon//icon to replace the standard iconImport Javax.swing.JOptionPane; Public classMessage { Public Static void Main(string[] args) {Joptionpane.showconfirmdialog (NULL,"This a warning!","warningdialog!", Joptionpane.yes_no_option, Joptionpane.warning_message);//joptionpane.showconfirmdialog (NULL, "This a warning!", "warningdialog!", Joptionpane.yes_no_cancel_option, Joptionpane.warning_message);}}//optiontype The number of different buttons is different


Enter the dialog box:

//ParametersParentcomponet//Parent ComponentMassage//Message Object displayed in dialog box (string, icon, component or array)Title//dialog box titleMessageType//message type, decision icon, value: Error_message,information_message,warning_message,question_message,plain_message oneIcon//icon to replace the standard icondefault         //default values presented to the user Public classMessage { Public Static void Main(string[] args) {String str= Joptionpane.showinputdialog (NULL,"Enter an integer","Input dialog box", joptionpane.plain_message);//Returns a string}}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

4 common dialog boxes for Joptionpane

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.