当前位置: 技术问答>java相关
请教java代码里的一个小问题?
来源: 互联网 发布时间:2015-09-23
本文导语: //site address String response2=JOptionPane.showInputDialog( null,"Enter the site address:"); address=new JTextField(response2,20); //site type String choices[]={"Personal","Commercial","Unknow"}; int response3=JOptionP...
//site address
String response2=JOptionPane.showInputDialog(
null,"Enter the site address:");
address=new JTextField(response2,20);
//site type
String choices[]={"Personal","Commercial","Unknow"};
int response3=JOptionPane.showOptionDialog(
null,"What type of site is it?","Site Type",0,
JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);
type=new JTextField(choices[response3],20); //??????????????
请问在site type里的type=new JTextField(choices[response3],20)是什么意思
为什么他没有像site address里的address=new JTextField(response2,20)那样
choices[response3]是啥意思?choices[]不是初始化过了吗,怎么有用这个??
String response2=JOptionPane.showInputDialog(
null,"Enter the site address:");
address=new JTextField(response2,20);
//site type
String choices[]={"Personal","Commercial","Unknow"};
int response3=JOptionPane.showOptionDialog(
null,"What type of site is it?","Site Type",0,
JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);
type=new JTextField(choices[response3],20); //??????????????
请问在site type里的type=new JTextField(choices[response3],20)是什么意思
为什么他没有像site address里的address=new JTextField(response2,20)那样
choices[response3]是啥意思?choices[]不是初始化过了吗,怎么有用这个??
|
response3 是一个变量呀,这个变量是由int response3=JOptionPane.showOptionDialog(
null,"What type of site is it?","Site Type",0,
JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);
来控制的,
showOptionDialog这是一个选项对话框
"what type of site is it?"--------显示的信息
Site Type--------title
用choice字符串数组的内容来显示在选项对话框内.Personal-----choice[0]是默认值. response3就是你在选项对话框中选得值.
null,"What type of site is it?","Site Type",0,
JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);
来控制的,
showOptionDialog这是一个选项对话框
"what type of site is it?"--------显示的信息
Site Type--------title
用choice字符串数组的内容来显示在选项对话框内.Personal-----choice[0]是默认值. response3就是你在选项对话框中选得值.
|
type=new JTextField(choices[response3],20)
其实,choices[response3]是数据组的索引项,它是用某一个元素的值来初始化JTextField的
其实,choices[response3]是数据组的索引项,它是用某一个元素的值来初始化JTextField的