Re: [fest-swing] How to shutdown an Swing application?

閲覧: 119 回
最初の未読メッセージにスキップ

Ernie

未読、
2013/05/24 13:51:402013/05/24
To: easyt...@googlegroups.com
Basic question: how would an end-user do this?

Are you asking how to build/cleanup the frame (developer side) or automate getting rid of it?

If it's the former, it's a more complicated answer (you have to set default close operation if it's a jframe, anything else in the class may need appropriate cleanup), if it's the latter, it's a simple matter of handling the objects like an end-user will.

On Wednesday, May 15, 2013 4:23:14 AM UTC-4, jiangs...@gmail.com wrote:
Hello,
I'm using fest-swing-1.2, and using ApplicationLauncher to start a Swing application, like,
public class FestDemo {

    public static void main(String[] args) throws Exception {
        String mainClassName = "ui.SimpleFrame";
        MyClassLoader classLoader = new MyClassLoader();
        Class<SimpleFrame> mainClass = (Class<SimpleFrame>) classLoader.loadClass(mainClassName);
        ApplicationLauncher.application(mainClass).start();
    }
}
It works well, but how can I shutdown the Swing app with fest-swing?

Because some of my test cases have to "restart" the Swing app. Namely,  in one test case, I have to shutdown it at first, and then start it again.
Please note that, the app must be shutdown completely. All of objects and class instances related to the Swing app must be destroyed (none of them is referenced).

As shown as FestDemo, I use a custom class loader(MyClassLoader) instance to load the main class(ui.SimpleFrame), and ensure creating a brand new main class instance at every launch.
But the problem is how to destroy previous SimpleFrame instances, or the memory will leak.

Thanks in advance!

Best regards,
Jiang Sha

Martin

未読、
2013/05/28 12:59:092013/05/28
To: easyt...@googlegroups.com
You would need to verify this, but you should be able to dispose() the frame that launches the application.  That should close the frame and release all the resources.  However that may not clean up all the application objects, and beyond that, even if all the application objects are no longer referenced, you have to wait until the garbage collector decides to clear up the garbage.

What exactly are you trying to test?  Startup time?  Shutdown time?  Memory usage?

You may not be able exactly measure each of these, but you can collect the data into a database or CSV file and keep track of the trend over time.
全員に返信
投稿者に返信
転送
新着メール 0 件