so my question is here how can I reset all the calculation and have a new total that will show up when the user enter two number's again.
Im not sure if i understand your question correctly. So sorry if my answer misses the point.
In your example, i understand you have a program with two input fields, one output field and a button that triggers the calculation? And you want to evaluate the input data and change the output field accoding to that?
If that is correct, i think what you are looking for ActionListener of some type. You need to listen for the button's onClick -event. When it triggers, you read the inputs, calculate the output and update the output field.
In semi pseudo code style:
...add( new Button("calculateButton") {
@Override
public void onClick() {
int firstInput = getFirstInput(); //implementation of getFirstInput() read the input field and does all the casting and null checks etc..
int secondInput = getSecondInput();
int result = calculate(firstInput, secondInput);
updateOutputComponent(result);
}
);
The point being that you need to listen for the clicking of the button and let that trigger actual calculation.
Read more about even listeners:
How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)