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.

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.