Home > Software engineering >  How to set double data type in tot text field
How to set double data type in tot text field

Time:12-27

I want to divide a double and show it in the text field. when I tried to set it in to set field it's not showing. I tried several tutorials but it want to help this problem. here is the java code I tried: `

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        double Width=Integer.parseInt(jTextField1.getText());
        double Hight=Integer.parseInt(jTextField2.getText());
        double SqFt=Width*Hight;
        double SqInch =SqFt/144;
        String r = String.valueOf(SqInch);
        jTextField4.setText(r);
        jTextField3.setEditable(false);
    }

`

I want to divide decimal numbers (ex:1.222,2.5) and display in it a text field but when I try this code it want show in the text field.

CodePudding user response:

have you initialized the textField correctly? can u send the code where it's initialized?

also if you want to convert the text into double use: Double.parseDouble

  • Related