Solved

Saving dirty data in Applet shutdown() lifecycle method issue

Posted on 2011-09-23
1
241 Views
Last Modified: 2012-06-21
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.isModifedConfigurations()) {
              int selection = 999;
              
            // Discard changes ?
            selection = JOptionPane.showConfirmDialog(null, messages.getString("ConfigPowerbarChangeConfirmMsg"),
                    messages.getString("ConfigPowerbarChangeConfirmMsgTitle"),
                    JOptionPane.YES_NO_OPTION);
           
            if (selection == JOptionPane.NO_OPTION) { //Discard Changes
                configurationManager.setModifedConfigurations(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.invokeAndWait(new Runnable() {
                                  public void run() {
                                        toolbarController = new ToolbarController(ToolbarModelFactory.getSystemwideToolbarModel());
                                          ApplicationEvent evt = new ApplicationEvent(ToolbarController.SAVE, toolbarController);
                                          toolbarController.handleApplicationEvent(evt);
                                       }
                              });
                        } catch (InterruptedException e) {
                              e.printStackTrace();
                        } catch (InvocationTargetException e) {
                              e.printStackTrace();
                        }
                 }
        }
    }


Suggestions ?

Paolo
0
Comment
Question by:ptreves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
ptreves earned 0 total points
ID: 36904415
Implement proper controller.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This video teaches viewers about errors in exception handling.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question