当前位置: 技术问答>java相关
问题啊~~~~~~~~~~~谢谢帮我看看~~在线~!
来源: 互联网 发布时间:2015-11-13
本文导语: 我编了个选择框(Choice()),然后我在上面加有匿名监听器,如下: c.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ String s; s = e.getItem(); if(s.equals(...
我编了个选择框(Choice()),然后我在上面加有匿名监听器,如下:
c.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
String s;
s = e.getItem();
if(s.equals("xingchen") == true){
t.setText("");
t.setText("is a MD");
}
if(s.equals("lanyanhuo") == true){
t.setText("");
t.setText("is a SG");
}
if(s.equals("jiubingzhiren") == true){
t.setText("");
t.setText("is a JS");
}
if(s.equals("touye") == true){
t.setText("");
t.setText("is a dia");
}
}
但编译时它说:
incompaeible types
found:java.lang.Object
required:java.lang.Sring
s = e.getItem();
^
c.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
String s;
s = e.getItem();
if(s.equals("xingchen") == true){
t.setText("");
t.setText("is a MD");
}
if(s.equals("lanyanhuo") == true){
t.setText("");
t.setText("is a SG");
}
if(s.equals("jiubingzhiren") == true){
t.setText("");
t.setText("is a JS");
}
if(s.equals("touye") == true){
t.setText("");
t.setText("is a dia");
}
}
但编译时它说:
incompaeible types
found:java.lang.Object
required:java.lang.Sring
s = e.getItem();
^
|
s = (String)e.getItem();
now are ok.
now are ok.