Java programmed calculator code error

Asked

Viewed 30 times

-1

The error message is this: it is not possible to find the symbol symbol: gettext method () location: txttela variable of type Jtextfield There are several errors, but it is the same. What I understand is that the gettext () and settext () method is missing in the jtextfield txttela variable, but I’m not able to do it, someone can answer for genteleza.
The error message is this:

cannot find symbol
symbol: methodgettext()
location: variable txttela of type jtextfield

the code is this:

private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        String corrente;
        corrente = txttela.getText();

        if (corrente.length() <= 0) {
            txttela.setText("0.");

    }                                         
        else {
            if (!existeponto(txttela.gettext())) {
                txttela.settext(txttela.gettext() + ".");
            }
        }

    }

    public static boolean existeponto(String corrente) {
        boolean resultado;
        resultado = false;
        for (int i = 0; i < corrente.length(); i++) {
            if (corrente.substring(i, i + 1).equals(".")) {
                resultado = true;
                break;
            }

        }
        return resultado;

    }

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        String corrente;
        corrente = txttela.gettext();

        if (corrente.length() > 0) {
            corrente = corrente.substring(0, corrente.length() - 1);
            txttela.settext(corrente);
        }
    }                                         

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        txttela.settext("");

    }                                         

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        String corrente;
        Double num;
        corrente = txttela.gettext();
        if (corrente.length() > 0) {
            num = 1 / (Double.parseDouble(corrente));
            txttela.settext(num.toString());
        }
    }                                         

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        Double num;
        String corrente;

        corrente = txttela.gettext();
        if (corrente.length() > 0);
        {
            num = (-1) * Double.parseDouble(corrente);
            txttela.settext(num.toString());
        }
    }                                        

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        if (!txttela.gettext().equals("")) {
            memoria1 = txttela.gettext();
            signo = "-";
            txttela.settext("");
        }
    }                                         

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        if (!txttela.gettext().equals("")) {
            memoria1 = txttela.gettext();
            signo = "+";
            txttela.settext("");
        }
    }                                         

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        if (!txttela.gettext().equals("")) {
            memoria1 = txttela.gettext();
            signo = "*";
            txttela.settext("");
        }
    }                                         

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        if (!txttela.gettext().equals("")) {
            memoria1 = txttela.gettext();
            signo = "/";
            txttela.settext("");
        }
    }                                         

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        String resultado;
        memoria2 = txttela.gettext();

        if (!memoria2.equals("")) {
            resultado = calculadora(memoria1, memoria2, signo);
            txttela.settext(resultado);
        }
    }                                         

    private void txttelaActionPerformed(java.awt.event.ActionEvent evt) {                                        
        setText("String");
        gettext();// TODO add your handling code here:
    } 

             

2 answers

0

Try changing gettext() to gettext()

0

It was probably a typo of yours, the correct method is getText(); and you used gettext(); lower-case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.