I agree with Ernest's approach, and it's certainly much clearer than the approach I suggested. I was trying to provide some 'food for thought' based on some snags i have run into in the past... kind of 'defensive programming':-)
As you may have seen in some earlier posts, I'm still struggling with 'best practices' for dealing w the Swing event Q myself ...
I can't get used to a single Q for GUI events, although I *think* I understand why it may have been architected this way [my "naive" theory is: because swing must be portable and operate the same across (theoretically 'any') gui windowing system, java must abstract a 'protected mode'-ish graphics kernel. i can only guess that swing's single asynch q simplifies 'kernel' programming/maint and awt backsupport ... as i say, it's a naive theory ...].
SwingWorker appears to acknowledge the limitations of Swing. The fact that it's not included in the SDK keeps some of us from shooting ourselves in the foot before we have learned enough about the particulars of Swing. Probably in the typical case, a programmer may never need a SwingWorker thread.
The bottom line is that we all wind up taking Swing design into account (eg _invokeLater) once the 'event-based' part of our need comes into play...
But to answer your question, I'm afraid I don't know of a 'best practices' type book. There was an author of a Swing book on this forum maybe a few months ago, and Gregg (moderator) asked him about this very topic. As I recall, the book didn't take a position on best practices, but offered various approaches. The book may have been reviewed elsewhere on this site. I don't believe the samples were online back then when I looked... but it's probably worth a look-see at the javaranch book reviews.
- I got (and get) most help from downloaded tutorials, examples, and open source:
1. The SwingSet2 demo that comes with the SDK is a tour-de-force of designs... I really like their initialization code, and the init infrastructure for launching the components. it's kind of a bean-starter lesson - a component-ized function orientation instead of the traditional top-down sequential design.
2. For open source, jEdit really impresses me, even though the code itself is way 'advanced java'. it may take a long while to understand the detail, but it's always instructive to study it. there are lots of neat tricks and thoughtful methods there...
3. Again on the 'advanced' side: if you want a case-study of a java e-mail filtering application using very advanced concepts (model-view-controller, thread pools, etc), you can download
BlackMamba. In this article the author explains how and why he chose to design the app the way he did.
4. Finally, if you check out a handful of Sun examples, you'll see a
pattern of their "_createAndShowGUI()" to get the main window displayed. The Sun coders are particularly mindful of the Q limitations, and by reviewing some of their examples, you'll begin to get a feel for when a deceptively simple need can trigger the need for a slew of defensive programming:^-)
hth!