1 Jul 2004 04:32
RE: Swing and garbage collection
John, A common idiom (for lack of a better word) with Swing apps is to have one parent JFrame, a lightweight class w/ main method for bootstraping the program (and no fields), and a few helper classes that resemble SwingUtilities to manage functionality that doesn't belong in any one class. An example would be a WindowUtilities class that provides a center(Window) function. Whether you use Singleton or static methods is an implementation detail. The helper classes tend to add some generic functionality and not much state. Similarly, a resource class can be used to externalize strings, load icons, etc. For persisting user preferences, checkout the Preferences API, which is easy to use and stores info in the registry when used on Windows. Also, if you are doing Swing, it's essential to get your head around the threading issues. Foxtrot is a library that makes Swing threading easier, and is easy to use itself: http://foxtrot.sourceforge.net/ The documentation describes the catch 22's of Swing threading. Also,you should use setVisible(boolean) instead of show/hide, which are deprecated as of 1.1. >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(Continue reading)

RSS Feed