Solved

Saving dirty data in Applet shutdown() lifecycle method issue

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 86
MacOS and programming in React 7 28
Spring Framework HTTPSession management 1 23
varialbe initialization 11 30
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

895 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