Home » Java » Convert String in Int

Convert String in Int

Posted by: admin June 14, 2018 Leave a comment

Questions:

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();
    }         
Answers: