Solved

Saving dirty data in Applet shutdown() lifecycle method issue

Posted on 2011-09-23
1
236 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
1 Comment
 

Accepted Solution

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

815 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now