> I read
> somewhere that I should do those things only in the "event dispatch
> thread", and that SwingUtilities.invokeLater(Runnable) would make that
> work. But I'm not sure if I get it yet; why would I need to do that?

The GUI runs in its own thread (the event thread). If you tried to
update the GUI directly from another thread, then the GUI thread would
be reading/painting while being updated, and would thus be
inconsistent and throw an exception. invokeLater gets around this, the
'other thread' sets a task up with the GUI thread will run as soon as
it gets around to it. I think you are following:
http://en.wikibooks.org/wiki/Clojure_Programming/Examples#Simple_GUI_:_Temperature_Converter
This code does not need invokeLater because the ActionListener gets
executed on the GUI thread anyway.
Note that this implies you should construct the GUI with invokeLater,
however there are some exceptions which make this unnecessary as you
will see:
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
The worker is overkill in this case, but if the calculation was very
long, then you would definitely want to use a worker to avoid locking
up the GUI thread and having your APP freeze.



--~--~---------~--~----~------------~-------~--~----~
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