Results 1 to 2 of 2
  1. #1
    ptreves is offline Member
    Join Date
    Sep 2011
    Rep Power

    Question Swing Applet losing dirty data


    In reaction to a button being pressed on a toolbar, the user is prompted if he wants to Discard his changes (dirty data). If he selects YES that he wants to Discard his changes the displayed applet is stopped and destroyed. Alternatively, if the user selects NO that he does not want to Discard his changes, I trick the application into saving his changes (dirty data). I force a ToolbarController.SAVE event which ties into a SaveAction Thread to force his changes.

    I want to allow enough time for the SaveAction thread to do its job, so I wrapped the code in a SwingUtilities.invokeAndWait thread method call.

    At runtime, the dirty data is lost. Is the SwingUtilities.invokeAndWait the proper method to use in this case ?

    Here is the code snippet:
    Java Code:
    public void shutdown() {
        if (configurationManager.isModifedConfigurations()) {
              int selection = 999;
            // Discard changes ?
            selection = JOptionPane.showConfirmDialog(null, messages.getString("ConfigPowerbarChangeConfirmMsg"),
            if (selection == JOptionPane.NO_OPTION) { //Discard Changes
            } 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);
                        } catch (InterruptedException e) {
                        } catch (InvocationTargetException e) {
    Last edited by Norm; 09-25-2011 at 03:32 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Swing Applet losing dirty data

    the dirty data is lost
    Can you explain what "data is lost" means?

Similar Threads

  1. NetBeans losing package information when crashing
    By Kethas in forum New To Java
    Replies: 4
    Last Post: 03-03-2010, 05:38 AM
  2. Processing dirty regions error.
    By tien1504 in forum Eclipse
    Replies: 4
    Last Post: 10-19-2009, 08:03 AM
  3. Losing Packets/Bytes using DataInputStream and socket
    By ajordanneve in forum Networking
    Replies: 0
    Last Post: 03-24-2009, 05:22 AM
  4. dirty object
    By venkatallu in forum New To Java
    Replies: 2
    Last Post: 09-06-2008, 10:15 AM
  5. Problems with JFrame losing the Design view
    By in forum NetBeans
    Replies: 7
    Last Post: 07-23-2008, 07:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts