I don't understand your sample code fully yet but it looks like the Dialog 
asking the question about saving etc is created in a new thread.

On Fri, 23 Oct 2009 10:46:59 am Todd Volkert wrote:
> In general, the UI isn't thread safe, so all UI operations should be done
> on the UI thread.  Why do you ask?
> -T
>
> On Thu, Oct 22, 2009 at 7:11 PM, Scott Lanham <li...@sael.com.au> wrote:
> > Thanks Todd, that is great.
> >
> > One question though. Is there any problem with creating a dialog in a
> > separate
> > thread to the main thread?
> >
> > On Fri, 23 Oct 2009 08:23:43 am Todd Volkert wrote:
> > > Hi Scott,
> > >
> > > First off, you can only do this in DesktopApplicationContext, since
> > > BrowserApplicationContext can't reliably prevent the applet from
> > > getting destroyed.  If you are in DesktopAplpicationContext, then the
> > > very short answer is that you return true from Application.shutdown()
> > > to prevent the shutdown until the user has answered your question. 
> > > Then, when they
> >
> > answer
> >
> > > your dialog (or sheet), you call DesktopApplicationContext.exit(), and
> > > allow the shutdown at that time.
> > >
> > > The long answer is that it's kinda tricky to get right.  To aid you on
> >
> > your
> >
> > > way, I'll blindly paste snippets of the source of my Pivot app that
> > > does exactly this - you should be able to gleam what you need from it.
> > >
> > > I've attached two snippet source files.  Let me know if they don't come
> > > through.
> > >
> > > -T
> > >
> > > On Thu, Oct 22, 2009 at 5:58 PM, Scott Lanham <li...@sael.com.au> wrote:
> > > > Hi All,
> > > >
> > > > I am at the point in my application where during Application.shutdown
> > > > I would
> > > > like a dialog to popup if they haven't saved their changes. The
> > > > dialog would
> > > > ask if they want to Save, Not Save, Cancel with the last cancelling
> > > > the shutdown. I am uncertain of how to approach this and was hoping
> > > > someone could
> > > > give me some guidance :-)
> > > >
> > > > Thanks,
> > > >
> > > > Scott.

Reply via email to