**
java 自学日记 —— 对话框小结**
**常用的对话框有 showconfirmdialog(询问一个确认的问题), showinputdialog (提示要求某些输出) , showmessagedialog (通知用户某事已经发生) showoptiondialog (上面的集大成者) , showinternallXxx (通常用于内置对话框);**
- showconfirmdialog
JOptionPane.showConfirmDialog(null, "你喜欢水果吗?","标题",JOptionPane.YES_NO_OPTION);
JOptionPane.showConfirmDialog(null," ", "picture ",JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, img);
2.showinputdialog
JOptionPane.showInputDialog(null, "按某些要求来书写","write",JOptionPane.PLAIN_MESSAGE,
img, a,a[1]);
String []a= {"aa","bb"};
JOptionPane.showInputDialog(null,"你喜欢什么水果");
- showmessagedialog
JOptionPane.showMessageDialog(null, "message");
- showoptiondialog
JOptionPane.showOptionDialog(null, " "," ",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,
img, a, a[1]);
5.showinternalXxx
test frame = new test();
frame.setVisible(true);
JInternalFrame ji = new JInternalFrame();
frame.add(ji);
ji.setVisible(true);
JOptionPane.showInternalMessageDialog(ji, "你是否爱好唱歌","爱好选择", JOptionPane.INFORMATION_MESSAGE);
参数 :
1.parentcomponent :他作为此对话框的父对话框的component 该参数为NULL时默认Frame作为父级
2.message 参数(不用多说,就是字面意思)
3. icon:在对话框中显示的图标
4. messagetype 参数: 只有固定5种;
5. options 参数 : 对底部选项进行更详细的描述;
6. initialvalue : 默认值;