[ajug-members] Swing and garbage collection
Fuqua, Andrew (ISSAtlanta)
AFuqua at iss.net
Thu Jul 1 10:14:50 EDT 2004
Why not just have the MainApp code pass itself to whoever needs it
before it finishes it's main()? Wouldn't that be the simplest thing? If
the other objects are hanging around, then MainApp must also.
From: ajug-members-bounces at ajug.org
[mailto:ajug-members-bounces at ajug.org] On Behalf Of John Wells
Sent: Tuesday, June 29, 2004 11:14 PM
To: ajug-members at ajug.org
Subject: [ajug-members] Swing and garbage collection
I have a swing application that is started by running a class called
MainApp. The class has a main method that creates an object of itself,
creates a number of different JFrames and populates a few of its own
fields with various objects. It's never meant to be seen...more of a
common entry way into the application.
The problem is that I'd like it to remain in scope, so that the fields
that it instantiates are accessible for the entire lifetime of the
application. This is because it creates a few common resources ( a
system tray icon if it's run on Windows, for example).
What's the accepted standard for persisting things like this in swing?
What is this even called, so that I might google efficiently?
Currently, as soon as the execution thread has passed through it, it's
gone. I tried causing it to extend JFrame and calling
objectname.hide(), but no luck, still garbage collected.
Thanks for the help!
ajug-members mailing list
ajug-members at ajug.org http://www.ajug.org/mailman/listinfo/ajug-members
More information about the ajug-members