Hello developers,

Is there something wrong with my code? Im getting the error message saying my method, actionPerformed_Plus cannot be applied to the () in actionPerformed_Plus.

public void button2_actionPerformed_Plus(ActionEvent e) {
      actionPerformed_Plus();          //says the method below cannot apply here???
   }

    public void actionPerformed_Plus(ActionEvent e){
      if(firstTime)
          {
            String firstNumber;
            firstNumber = textField1.getText();
            Double numberDouble1 = Double.valueOf(firstNumber);
            number1 = numberDouble1.doubleValue();
            result = result + number1; 
            String displayResult = String.valueOf(result);
            textField1.setText(displayResult);
            operator = "+" ; }
       else
          {
            String firstNumber;
            firstNumber = textField1.getText(); 
            Double numberDouble1 = Double.valueOf(firstNumber);
            number1 = numberDouble1.doubleValue();
            textField1.setText(firstNumber);
            operator = "+";
            firstTime = false; 
            return;
          }
    }

1. Must "ActionEvent e" occur only within button2_actionPerformed, and not
actionPerformed_Plus?

Thanks in advance.

Because your method signature takes a single parameter "ActionEvent e" and you are trying to call it with no parameters. There is no method signature actionPerformed_Plus() defined.

This article has been dead for over six months. Start a new discussion instead.