I have been searching around quite a bit about this topic but never got any satisfaction about any answers so ended up asking a question here :). Anyways,
from this similar post it was clear that dispose() does not terminate all the processes and still has remains in the task manager(the AWT process is not terminated completely) even after the JFrame is closed.
So, my question is :-
this.dispose() cleans off every child process after disposing the JFrame? or setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); does this job instead.Thanks, any suggestion on this is appreciated.
To answer 1.
dispose() on a JFrame will destroy the window and have the operating system clean up after it, if its the only JFrame left, the Java VM might terminate. So, in summary, it will close the window, and if the JFrame is the last remaining window of your application, it might (or might not) terminate your VM.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) however, will call System.exit() when the JFrame is closed, terminating the VM regardless of there being any other active JFrames in your app.
So, they are two different things :-)
To answer your second question, you could test it. But honestly, I wouldn't be to worried about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With