0
votes

In my private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) I have error message:

incompatible types: String cannot be converted to int

My first field (IdentCat) is normaly an Int. However I don't know how to do this in INT ?

ap.setIdentCat(jTextIdent.getText().toUpperCase());

More of code

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();
    }         
2
You can’t pass a string value where an int is required. You need to call the ParseInt function - King

2 Answers

5
votes

Use Integer.parseInt("123456").

3
votes

Use Integer.valueOf("string") as alternative too! This will return an Integer object.

String number = "10";
Integer result = Integer.valueOf(number);