Re: File browser
Peter Duniho wrote:
I don't think I can fully understand the recommendation or the
assertion that something might break until I know exactly how it would
break and under what circumstances that might happen.
RedGrittyBrick wrote:
This looks promising:
http://www.javaworld.com/javaworld/jw-08-2007/jw-08-swingthreading.html
How long did that take to Google up? Not very, I'll wager.
Lew:
How you interpret that is up to you. But Sun has warned us that running
GUI events *off* the EDT /might/ work.
Peter Duniho wrote:
I'm not talking about "running events".
Not "events" in the sense of EventListener, but events like calling a method,
which you do when you invoke, e.g., "new JFrame()".
If you have a point to make, surely you have some reference that supports the point.
Op. cit. upthread.
Telling someone to Google for that reference when you already know what it is is just lame.
Why do you think that pertains? If I already knew what it was I certainly
would have posted it, and did, for one such. What's lame about that? I
simply said that there's more evidence out there and it can be found. RGB's
rapid discovery of a relevant article is evidence for that. Now let's move
off the /ad hominem/ arguments and stick to the topic, hm?
Peter:
But as far as initialization goes, there's ample ambiguity here, in the documentation,
in the tutorials, and in sample code I've seen all over the place.
Information that was published before Sun realized, as they now shamefacedly
admit, that they've been putting out wrong information.
Just look at how long people still cite Vector and Hashtable, classes that
were supplanted in 1998 before most practitioners today had learned Java, to
see how long it takes old information to vanish.
The presence of wrong information out there doesn't make bad practices viable.
Here's the salient quote from RedGrittyBrick's JavaWorld link:
The correct way to start up a Swing GUI today differs from Sun's originally prescribed approach.
Here's the quote from the Sun documentation again:
Once a Swing component has been realized, all code that might affect or depend on the state
of that component should be executed in the event-dispatching thread.
Now throw those instructions out the window, because around when JSE 1.5 was released all the
examples on Sun's site changed. Since that time it has been a little-known fact that you are
supposed to always access Swing components on the event-dispatch thread to ensure their thread
safety/single-threaded access. The reason behind the change is simple: while your program might
access a Swing component off of the event-dispatch thread before the component is realized, the
initialization of the Swing UI could trigger something to run on the event-dispatch thread
afterward, because the component/UI expects to run everything on the event-dispatch thread.
Having GUI components run on different threads breaks Swing's single-threaded programming model.
That should give you the hints you need to construct an example that fails if
you don't initialize on the EDT.
--
Lew