My application shall switch programmatically from one to another main Window (that means the first window should get closed, then the second window should get opened).
The switch shall be executed within an ActionListener
object which is added to window1. The actionPerformed(ActionEvent e)
method here looks like this:
@Override
public void actionPerformed(ActionEvent e) {
WindowStarter.closeConfigWindow();
WindowStarter.openMainWindow();
}
where closeConfigWindow()
is:
public static void closeConfigWindow() {
if (window1 != null)
window1.dispose();
}
In the java-doc you can find the following information related to the dispose()
method of the Window
class:
Note: When the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for more information
So my question is:
Do I risk that the application terminates when the method gets called?
(because: the Listener Object is only related to the instance of window1, after disposing that window, all objects related to that instance are "off the JVM hook". So the application should terminate theoretically?)
Or asked otherway round:
Why doesn't the application terminate despite that?
thanks in advance