Samppi -

On Jan 28, 12:53 pm, samppi <rbysam...@gmail.com> wrote:
> Thanks for the replies, everyone. I read in an article that one of the
> most common Swing mistakes is putting non-GUI work into the event
> dispatch thread, but it seems like oftentimes the cost of creating a
> new thread outweighs the benefit of separation, if the work is simple.
> With the code above, I was trying to figure out how to do a Swing app
> while performing potentially long procedure, such as contacting a
> different connected computer.

In that case, yes, you should do the time consuming work on a
different thread.

>
> But for Keith's comments—when would it good to block the Swing thread?
> Even if I wanted to disable the control that started the action,
> shouldn't I just use (.setEnabled button false)? I'd think that the
> GUI should always be able to respond to the user, or else it would
> seem frozen.
>

I'm not sure what you mean by this.  If you are doing the work on the
Swing (AWT) thread, there is no need to disable any components because
the GUI will not accept any input until your work is done.  If you do
the work on a different thread, then, yes, you would need to call
setEnabled to disable the button.  And there may be other things you
need to disable (a program exit command, for example).

> I guess it'd be bad with multiple modal dialogs. I think maybe I
> should just try to avoid those. :)

There is a meme that has been going around for years that "modal
dialogs are evil".  This use case would certainly support that
view. ;)

Regards,
Keith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to