Cancel Timer together with form close
I've faced with the following problem: I have a Timer I initialize and start during the form execution. Then I need to cancel this timer when this form is replaced by some other form. The deal is: how to catch the event of form closure to put timer.cancel() there? Or is there any workaround?
Sure I could put a code into actionPerformed() method of backCommand, but unfortunately form change in my application is not driven by user actions only but also by some events so this solution is not enough.
Thank you in advance for any advice!