Your problem is here.
if(e.getSource() == b2)
input.setText("");
output.setText("");
You probably intended to write this.
if(e.getSource() == b2) {
input.setText("");
output.setText("");
}
But because you left out the curly braces, blanking out output
happens every time this method runs, not just if the button that triggered the event is b2
.