ptreves
asked on
Saving dirty data in Applet shutdown() lifecycle method issue
Hello,
I have written code for a Java Applet shutdown() lifecycle method.
The issue I am having is that when I click a powerbar button on a top level frame, I lose my dirty data.
For some reason, the following code snipped is not doing its job.
What I want is to allow enough time for dirty data to be save before killing my applet and changing my display.
Here is the code snippet:
public void shutdown() {
if (configurationManager.isMo difedConfi gurations( )) {
int selection = 999;
// Discard changes ?
selection = JOptionPane.showConfirmDia log(null, messages.getString("Config PowerbarCh angeConfir mMsg"),
messages.getString("Config PowerbarCh angeConfir mMsgTitle" ),
JOptionPane.YES_NO_OPTION) ;
if (selection == JOptionPane.NO_OPTION) { //Discard Changes
configurationManager.setMo difedConfi gurations( false);
super.shutdown();
removeBindings();
stopCurrentApplet();
} else if (selection == JOptionPane.YES_OPTION) { //Force Save changes
System.out.println("Catch ApplicationEvent !!! Force Save of Mutable Table fields.");
try {
SwingUtilities.invokeAndWa it(new Runnable() {
public void run() {
toolbarController = new ToolbarController(ToolbarM odelFactor y.getSyste mwideToolb arModel()) ;
ApplicationEvent evt = new ApplicationEvent(ToolbarCo ntroller.S AVE, toolbarController);
toolbarController.handleAp plicationE vent(evt);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
Suggestions ?
Paolo
I have written code for a Java Applet shutdown() lifecycle method.
The issue I am having is that when I click a powerbar button on a top level frame, I lose my dirty data.
For some reason, the following code snipped is not doing its job.
What I want is to allow enough time for dirty data to be save before killing my applet and changing my display.
Here is the code snippet:
public void shutdown() {
if (configurationManager.isMo
int selection = 999;
// Discard changes ?
selection = JOptionPane.showConfirmDia
messages.getString("Config
JOptionPane.YES_NO_OPTION)
if (selection == JOptionPane.NO_OPTION) { //Discard Changes
configurationManager.setMo
super.shutdown();
removeBindings();
stopCurrentApplet();
} else if (selection == JOptionPane.YES_OPTION) { //Force Save changes
System.out.println("Catch ApplicationEvent !!! Force Save of Mutable Table fields.");
try {
SwingUtilities.invokeAndWa
public void run() {
toolbarController = new ToolbarController(ToolbarM
ApplicationEvent evt = new ApplicationEvent(ToolbarCo
toolbarController.handleAp
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException
e.printStackTrace();
}
}
}
}
Suggestions ?
Paolo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.