我首先引用this并像这样编辑..同名组合框名称。但是当我调用此方法时,它要求keyEvent..for我应该怎么做。这个代码是否有任何错误< / p>
ResultSet rset;
public void srKeyTyped(java.awt.event.KeyEvent evt){
String sch = ((JTextField)ComboItemName.getEditor().getEditorComponent()).getText();
try {
rset = new JDBC.DB().getData("SELECT * FROM item_reg WHERE id = '"+sch+"'");
} catch (Exception e) {
System.out.println(e);
}
ComboItemName.removeAllItems();
try {
while (rset.next()) {
String item = rset.getString("id");
ComboItemName.addItem(item);
}
} catch (SQLException ex) {
System.out.println(ex);
//Logger.getLogger(dataprocess.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(sch);
ComboItemName.setSelectedItem(null);
ComboItemName.setPopupVisible(true);
((JTextField)ComboItemName.getEditor().getEditorComponent()).setText(sch);
}