【发布时间】:2018-11-07 09:19:28
【问题描述】:
在我的私人 void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) 我有错误信息:
不兼容的类型:String 无法转换为 int
我的第一个字段(IdentCat)通常是一个 Int。 但是我不知道如何在 INT 中做到这一点?
ap.setIdentCat(jTextIdent.getText().toUpperCase());
更多代码
private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Categorie ap = new Categorie();
ap.setIdentCat(jTextIdent.getText().toUpperCase());
ap.setDenomCat(jTextDescr.getText());
boolean ok = daoCat.insertCategorie(ap);
if (!ok)
JOptionPane.showMessageDialog(null,"Insertion impossible !","Avertissement",JOptionPane.ERROR_MESSAGE);
this.dispose();
}
【问题讨论】:
-
您不能在需要 int 的地方传递字符串值。你需要调用 ParseInt 函数