Why the new JFrame terminates the application when we close it?
Lets investigate.
So lets opent the NewForm code and look the code.
Observe the line were the WindowBuilder generated the default close operation.
It commands the JFrame to EXIT_ON_CLOSE
Then the garbage collector completes the job.
Not this garbage collector :D
the JVM garbage collector.
What we should do is to replace the EXIT_ON_CLOSE with DISPOSE_ON_CLOSE
The logic behind this is to keep the main application on memory and only dispose the new form.
if you are implementing data persistance (database connections, xml, etc.) its a good idea to save and close the connections.
Lets investigate.
So lets opent the NewForm code and look the code.
Observe the line were the WindowBuilder generated the default close operation.
It commands the JFrame to EXIT_ON_CLOSE
Then the garbage collector completes the job.
Not this garbage collector :D
the JVM garbage collector.
What we should do is to replace the EXIT_ON_CLOSE with DISPOSE_ON_CLOSE
The logic behind this is to keep the main application on memory and only dispose the new form.
if you are implementing data persistance (database connections, xml, etc.) its a good idea to save and close the connections.
No comments:
Post a Comment