windowClosing(WindowEvent e) execution delayed
posted 5 years ago
I am using a JDialog in which I have various JComponents such as JRadioButton, JCheckBox, and JTextField classes. When a user closes the Dialog using the x button of the Dialog itself, the Components are programmed be left in their original state, which in this case is unselected or JTextField empty. I have created a method called restoreControls() to restore the Components this way. I have placed this method in the windowClosing(WindowEvent e) method as seen below. The content of the method is executed AFTER a time delay of a mere fraction of a second because when the Dialog is requested to become visible (it is set to be hidden instead of destroyed), the text in the JTextField is seen during this very brief delay, but it does disappear as programmed to do so. I cannot understand why the method is not executed right after the Window is closed. I have tried windowClosed(WindowEvent e), and it is the same effect. I have tried wrapping the Component methods such as setSelected(false) or setText("") in an evokeLater() method and it makes no difference.