请帮忙,有关JComboBox的问题
程序代码:
String gdate=new String(); //注明,addItem()中用的是字符串 public void itemStateChanged(ItemEvent e){ if(e.getSource()==f1){ //注明,f1.addItem()中用的是字符串 gdate=e.getItem(); b1=Integer.parseInt(gdate);//把字符串gdate转换为int型的 } if(e.getSource()==f2){ //注明,f2.addItem()中添加的选项是字符串 gdate=e.getItem(); b2=Integer.parseInt(gdate); } if(e.getSource()==f3){ //注明,f3.addItem()中添加的选项是字符串 gdate=e.getItem(); b3=Integer.parseInt(gdate); }程序能编译但,出现这结果:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException:javax.swing
at lixi.itemStateChanged(lixi.java:203)// gdate=(String)e.getSource();
at javax.swing.JComboBox.fireItemstateChanged(Unknown Source)
at javax.swing.JComboBox.selectedItemChanged(Unknown Source)
at javax.swing.JComboBox.contentsChanged(Unknown Source)
at javax.swing.AbstravtListModel.fireContenteChanged(Unknown Source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
请帮忙弄下,是什么原因??其中lixi]为class类,也是文件名