 <pre><code>public void actionPerformed(ActionEvent e) { String[] outputBoxButtonsPressed = outputBox.getText().split( " "); System.out.println(Arrays.toString(outputBoxButtonsPressed)); int answer = 0; boolean firstOperatorBeenUsed = false; for (int buttonPressed = 0; buttonPressed &lt; outputBoxButtonsPressed.length - 2; buttonPressed++) { if (outputBoxButtonsPressed[buttonPressed + 1].equals("+") &amp;&amp; !firstOperatorBeenUsed) { answer = answer + Integer .parseInt(outputBoxButtonsPressed[buttonPressed]) + Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); System.out.println(answer); firstOperatorBeenUsed = true; } else if (outputBoxButtonsPressed[buttonPressed + 1] .equals("+") &amp;&amp; firstOperatorBeenUsed) { answer = answer + Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); } if (outputBoxButtonsPressed[buttonPressed + 1].equals("-") &amp;&amp; !firstOperatorBeenUsed) { answer = answer + Integer .parseInt(outputBoxButtonsPressed[buttonPressed]) - Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); System.out.println(answer); firstOperatorBeenUsed = true; } else if (outputBoxButtonsPressed[buttonPressed + 1] .equals("-") &amp;&amp; firstOperatorBeenUsed) { answer = answer - Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); } if (outputBoxButtonsPressed[buttonPressed + 1].equals("x") &amp;&amp; !firstOperatorBeenUsed) { answer = answer + Integer .parseInt(outputBoxButtonsPressed[buttonPressed]) * Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); System.out.println(answer); firstOperatorBeenUsed = true; } else if (outputBoxButtonsPressed[buttonPressed + 1] .equals("x") &amp;&amp; firstOperatorBeenUsed) { answer = answer * Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); } if (outputBoxButtonsPressed[buttonPressed + 1].equals("÷") &amp;&amp; !firstOperatorBeenUsed) { answer = answer + Integer .parseInt(outputBoxButtonsPressed[buttonPressed]) / Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); System.out.println(answer); firstOperatorBeenUsed = true; } else if (outputBoxButtonsPressed[buttonPressed + 1] .equals("÷") &amp;&amp; firstOperatorBeenUsed) { answer = answer / Integer .parseInt(outputBoxButtonsPressed[buttonPressed + 2]); } } outputBox.setText(outputBox.getText() + " = " + answer); } </code></pre> <p>Is this new equals button handler which works perfectly with all buttons. Yay :D</p>