[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ajug-members]: Sharing data among Swing windows
John,
You can use Singleton [GoF95] to share global objects. Luckily, Swing is a
single threaded so you would not need to synchronize your global objects.
Another useful pattern is the Madiator [GoF95]. You can read about these
patterns in books such as "Patterns in Java" , ISBN 0-471-25839-3
If you are new to swing then you may want to explore the "SwingWorker". I
find this article very useful
http://www.javaworld.com/javaworld/jw-06-2003/jw-0606-swingworker.html.
Do not forget, Swing is single threaded. If you block the swing thread you
GUI is dead.
Best of luck
Stefan.
|-----Original Message-----
|From: John Wells [mailto:jb@sourceillustrated.com]
|Sent: Sunday, May 30, 2004 11:01 PM
|To: ajug-members@ajug.org
|Subject: [ajug-members]: Sharing data among Swing windows
|
|
|Guys,
|
|I'm rather new to Swing development on a large scale, and am beginning
|work on a multi-windowed application.
|
|What's the preferred method of sharing data between windows? In other
|words, suppose for illustration that I had a main class that was first run
|and that would initiate a database connection, and that I wanted to share
|that connection with all other windows in the application, each of which
|could be spawned in response to different events. How should/could I make
|that connection object accessible? I've done some googling, but probably
|am not keying in the correct buzz words.
|
|Thanks as always for your help!
|
|John
|
|