[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ajug-members]: Sharing data among Swing windows
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
Do not forget, Swing is single threaded. If you block the swing thread you
GUI is dead.
Best of luck
|From: John Wells [mailto:email@example.com]
|Sent: Sunday, May 30, 2004 11:01 PM
|Subject: [ajug-members]: Sharing data among Swing windows
|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!