JOptionpane类常用的四种方法
showMessageDialog();—-消息对话框
showConfirmDialog();—-选择对话框
showOptionDialog();—-自定义选择对话框
showInputDialog();—-输入对话框
JOptionPane类的参数
parentComponent —-设置对话框的父级容器(组件)
message —————-消息内容
title ———————对话框标题
messageType ———-消息类型,每种消息类型提供一个默认的图像
icon ———————设置自定义对话框的图像
optionType ————-按钮类型
options ——————自定义按钮数组,自定义选项按钮的文字
initalValue ————–设置默认选中的按钮
selectionValues———自定义选项数组,用于定义下拉框
initialselectionValue —设置默认选中的选项
parentComponent :对话框会显示在容器的中心,如果没有指定及传入null,则对话框采用缺省的Frame作为父窗口,即对话框会显示在屏幕的中心位置
showMessageDialog();
参数格式:
JOptionPane.showMessageDialog(parentComponent, message, title, messageType, icon);
messageType的默认值为JOptionPane.INFORMATION_MESSAGE,title的默认值为”消息”
messageType
JOptionPane.WARNING_MESSAGE———警示框
JOptionPane.INFORMATION_MESSAGE –普通提示框
JOptionPane.ERROR_MESSAGE————-错误提示框
JOptionPane.QUESTION_MESSAGE———问题框