Dialogs are divided into: modal and modeless, patterns will mean blocking execution of other threads, indicating the importance of the operation
1. Message dialog box
belong to modal dialog box
Format: public static void Showmessagedialog (Component parentcomponent,string message,string title,int messageType)
parentcomponent specifies where the dialog box is visible, NULL indicates the front of the screen, and not empty indicates that the component is centered in front of the display
message specifies the content, title specifies the dialog box title
MessageType indicates the type of dialog box
Information_message message dialog box
Warning_message warning Dialog box
Error_message error dialog box
Question_message Problem dialog box
Plain_message Simple dialog box
String str= jtextfield1.gettext (); String regex= "[a-za-z]+"; if (Str.matches (regex)) { Joptionpane.showmessagedialog (this, "121212", "Sasasa", joptionpane.warning_message); } Else { joptionpane.showmessagedialog (null, "121212", "Sasasa",joptionpane.information _message); Jtextfield1.settext (null); }
Initial Knowledge dialog box