Link to home
Start Free TrialLog in
Avatar of matthew016
matthew016Flag for Belgium

asked on

Execute instructions before JTabbedPane change of tabulation

Hi,
I use JTabbedPanes,
in one of them the user can do operations that need to be saved (JButton Save).
But if he choose another Tabulation without saving everything is lost.
How can I ask the user to save the operations before the JTabbedPane change of Tabulation ?
Thank you for any help.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of matthew016

ASKER

That's the way my programs works.
I can't really explain this shortly.
But in my tabulations I have JPanels but they have not the method addChangeListener.
I see that I can use ComponentListener
componentHidden(ComponentEvent e)
componentShown(ComponentEvent e)

Ok I have several problems when I use a ComponentListener:

1.The event is called after the tab is changed, so I have my JOptionPane above the new tab clicked.

2.I tought I could ask the user to Save with options Yes, No, Cancel
   And when he clicks cancel the tab shouldn't change, do u think it is possible to do that ?
It's difficult to assist you only knowing the vaguest details. Suffice it to say at this stage that it's possible to autosave continuously, which i would imagine would cure the problem
:-)