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