I have an application in which there is a textbox and a button. the textbox has focusListener(for incorrect values) and the button has actionListener(for saving the value into a file). An error message window pops up when a wrong value is entered in the textfield as soon as it loses focus. Now I have 2 senarios.
when the focus is lost from tab out and if a wrong value is entered in the field then the pop up window shows up correctly.
But when i enter a wrong value in the field and without tab out I click the button then the actionListener is activated before the focusListener(Focus Lost) and it saves the wrong value in the text file and then shows the error message.
How should I stop the incorrect value to be saved into file by running the focuslistener first?
Focus, FocusListener, Focus Subsystem is asyncronous, you can sheduling those events, but can caused another side effects, I'd suggest don't do that
delay required events in EDT by using
invokeLater
,