生活随笔
收集整理的這篇文章主要介紹了
JOptionPane的常用4种对话框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
JOptionPane類有4個用于顯示對話框的靜態方法:
消息,選項,確認,輸入對話框
showMessageDialog:
showConfirmDialog:
showOptionDialog:
showInputDialog:
消息對話框有如下方法:
parentComponet
massage
title
messageType
icon
import javax.swing.JOptionPane;
public class Message {
public static void main(String[] args) {JOptionPane.showMessageDialog(
null,
"This is Message!",
"MessageDialog", JOptionPane.QUESTION_MESSAGE);}
}
選項對話框有如下方法:
parentComponet
massage
title
messageType
optionType
icon
otptions
確定對話框:
parentComponet
massage
title
messageType
optionType
icon
import javax.swing.JOptionPane;
public class Message {
public static void main(String[] args) {JOptionPane.showConfirmDialog(
null,
"This a warning!",
" WarningDialog!", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);}
}
輸入對話框:
parentComponet
massage
title
messageType
icon
default
public class Message {
public static void main(String[] args) {String str= JOptionPane.showInputDialog(
null,
"輸入一個整數",
"輸入對話框", JOptionPane.PLAIN_MESSAGE);}
}
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔為你收集整理的JOptionPane的常用4种对话框的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。