我有这个代码,我想从jcomboBox获取所选项目,但是当我运行我的项目时,它给我复制打印所选项目的值和java.Lang.NullPointerException
这是代码:
private void jComboBox4ItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
if (evt.getStateChange()==ItemEvent.SELECTED){
String a=String.valueOf(jComboBox4.getSelectedItem());
System.out.print(a);
try{
String del2="select distinct PTYPE from Projects inner join project on projects.PNUMBER=(select pro_id from project where pro_name='"+a+"')";
psst=con.prepareStatement(del2);
String td2;
DefaultComboBoxModel mode2 = new DefaultComboBoxModel();
ResultSet RSS=psst.executeQuery();
while(RSS.next()){
td2=RSS.getString("PTYPE");
mode2.addElement(td2);
jComboBox7.setModel(mode2);
}
}
catch(sqlException ex){
JOptionPane.showMessageDialog(null,ex.toString());
}
}
最佳答案
原文链接:https://www.f2er.com/java/437306.html