470,832 Members | 2,075 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,832 developers. It's quick & easy.

Idiom for Swing apps with the "new" thread-safety concern?


I have decided to look again at Java after a *really* long break. While
browsing through the Swing tutorials [1], I noticed that the basic
skeleton of the demo applications had something new. There is now a
concern with thread-safety which is illustrated by the use of the
SwingUtilities.invokeLater() method for the GUI manipulation code.

In the demos, the private static method which is responsible for setting
up the GUI (createAndShowGUI) uses local instances in order to create
the main window and other Swing components as opposed to having the user
class actually extend JFrame and contain references to its child
components (JLabel, JButton, etc.). Is this how it should be done now?
What about having easy access to the frame's components? In case
extending from JFrame is still a current practice, could anyone describe
the idiom for it, if any? In other words, what would a basic Swing
application with a user class extending JFrame and the thread-safety
concern in place look like?

[1] http://java.sun.com/docs/books/tutorial/uiswing/learn/

Thank you,

Ney André de Mello Zunino
Jul 18 '05 #1
0 2804

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Ola Johansson | last post: by
51 posts views Thread by Tony Sinclair | last post: by
9 posts views Thread by Ben Bacarisse | last post: by
43 posts views Thread by Bill H | last post: by
350 posts views Thread by Lloyd Bonafide | last post: by
30 posts views Thread by Medvedev | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.