Solved

Saving dirty data in Applet shutdown() lifecycle method issue

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

758 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

14 Experts available now in Live!

Get 1:1 Help Now