Re: Help! Swing & Threads
Thanks very much to everyone who replied, you've all been very
Thomas Weidenfeller wrote:
For modal windows (like JFileChooser), the event pump is replaced by one
which only processes events for the particular window. It is often
claimed that the event dispatching thread is replaced, but studying the
code indicates otherwise.
Ah ha! You know, I don't see anywhere it is mentioned that the
JFileChooser is modal and *supposed* to block events from other
windows. I think this was 99% of my conceptual error.
P.S. Where to you get the source to look at?
The thing is, the issue is rather simple. You have to be careful with
one thread, the EDT. You almost always have to call the GUI on that
thread (when in doubt, better play it save then sorry and use a Runnable
and invokeLater()). You better don't block that thread. Modal windows
don't block that thread. Thats it.
Just curious: if I make a seperate object A which implements
Runable, and have that object invoke the JFileChooser, then call
invokeLater() with object A, is the EDT going to get terribly
I'm thinking that the first time object A runs, it'll tie up the
EDT anyway and still no events will fire for other windows.
Making a non-modal file chooser seems rather hard...