java中的消息提示框

2018/04/07 20:18:00

提到消息提示框必须提到的一个类是:javax.swing.JOptionPane


使用示例:

JOptionPane.showMessageDialog(null,"我是消息对话框",“标题”,JOptionPane.PLAIN_MESSAGE)

主要用到四种消息提示框方法:

(一)showInputDialog()输入对话框


(二)showOptionDialog()选择对话框

(三)showConfirmDialog()确认对话框


(四)showMessageDialog()消息对话框


先详细说明消息对话框,即JOptionPane.showMessageDialog()

有五种消息类型,类型不同,图标不同:

1、ERROR_MESSAGE


2、WARNINGMESSAGE


3、INFORMATIONMESSAGE


4、PLAINMESSAGE


5、QUESTIONMESSAGE


6、缺省的是默认为普通提示框


JOptionPane有三种参数设置类型

JOptionPane.showMessageDialog有三种参数设置 
JOptionPane.showMessageDialog(parentComponent, message); 
JOptionPane.showMessageDialog(parentComponent, message, title, messageType); 

JOptionPane.showMessageDialog(parentComponent, message, title, messageType, icon);

参数说明

parentComponent: 是对话框所在容器

message:是提示消息

title:是消息提示框的标题

messageType:是消息类型

icon:自定义图标


猜你喜欢

转载自blog.csdn.net/qll19970326/article/details/79694519