User can handle defaultclose operation with 4 options as following :
- HIDE :Hide hides the JFrame but do not pause the task of that window .Ex . If a JFrame plays a video , after clicking on hide button only the frame can be hidden. User can make the frame visible.It does not need to write any code.
- EXIT :
It exits the frame. EXIT_ON_CLOSE abruptly terminates all the threads of the JFrame. And frees the object of that frame.
[box type="shadow" ]setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);[/box] - DO_NOTHING :
As the name suggests DO_NOTHING frame does nothing with the frame. All the tasks continues after clicking on the close button.No changes are made in the JFrame.
[box type="shadow" ]setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);[/box] - DISPOSE :
DISPOSE on close is works same as HIDE with a thin difference line.It hides JFrame but the tasks of JFrames are performed in the background.The difference between HIDE and DISPOSE is the disposed JFrame can not be make visible.
[box type="shadow" ]setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);[/box]
Comments
Post a Comment