Java GUI彈出對話方塊中的幾種方式

2021-08-08 14:55:43 字數 1399 閱讀 8456

1.顯示乙個錯誤對話方塊,該對話方塊顯示的 message 為 'alert':

joptionpane.showmessagedialog(null, "alert", "alert", joptionpane.error_message); 

2.顯示乙個內部資訊對話方塊,其 message 為 'information': 

joptionpane.showinternalmessagedialog(frame, "information","information", joptionpane.information_message); 

3.顯示乙個資訊面板,其 options 為 "yes/no",message 為 'choose one': 

joptionpane.showconfirmdialog(null, "choose one", "choose one", joptionpane.yes_no_option); 

4.顯示乙個內部資訊對話方塊,其 options 為 "yes/no/cancel",message 為 'please choose one',並具有 title 資訊: 

joptionpane.showinternalconfirmdialog(frame, 

"please choose one", "information", 

joptionpane.yes_no_cancel_option, 

joptionpane.information_message); 

5.顯示乙個警告對話方塊,其 options 為 ok、cancel,title 為 'warning',message 為 'click ok to continue': 

object options = ; 

joptionpane.showoptiondialog(null, "click ok to continue", "warning", 

joptionpane.default_option, joptionpane.warning_message, 

null, options, options[0]); 

6.顯示乙個要求使用者鍵入 string 的對話方塊: 

string inputvalue = joptionpane.showinputdialog("please input a value"); 

7.顯示乙個要求使用者選擇 string 的對話方塊:

object possiblevalues = ; 

object selectedvalue = joptionpane.showinputdialog(null, "choose one", "input", 

joptionpane.information_message, null, 

possiblevalues, possiblevalues[0]);

彈出對話方塊

先定義 private view view private alertdialog mprotocoldialog 彈出對話方塊 private void loadprotocol mprotocoldialog new alertdialog.builder this settitle getst...

彈出對話方塊

call function popup to confirm exporting titlebar diagnose object text question anything else?text button 1 yes?icon button 1 15 text button 2 no 002 ...

彈出對話方塊

data answer 20 type c.call function popup to confirm exporting titlebar diagnose object text question anything else?text button 1 yes?icon button 1 15...