I have two JFormattedTextField objects on my JFrame object. I want a basic Math (addition) by the values of these JFormattedTextField
I think you should use a PropertyChangeListener, see How to Write a Property Change Listener.
There is an example using JFormattedTextField:
//...where initialization occurs:
double amount;
JFormattedTextField amountField;
...
amountField.addPropertyChangeListener("value",
new FormattedTextFieldListener());
...
class FormattedTextFieldListener implements PropertyChangeListener {
public void propertyChanged(PropertyChangeEvent e) {
Object source = e.getSource();
if (source == amountField) {
amount = ((Number)amountField.getValue()).doubleValue();
...
}
...//re-compute payment and update field...
}
}