No effect of setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

+1 pratt 15 · July 30, 2014
Hey anybody noticed that , when using GUI's in java if you do not declare
obj.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
then the Frame still runs and close when you click the "X" button. Can anybody explain me why is it so??


Post a Reply


Oldest  Newest  Rating
0 Brandon Elliott · July 30, 2014
Yes it will still run but it won't actually close if you click the close button. It will still be running but the frame will be hidden, as Brano explained

So for example say you don't set EXIT_ON_CLOSE and you run the program and "close" it 100 times, there will be 100 processes still running in the background, which is not good.
0 pratt 15 · July 30, 2014
@Brandon Elliott 

Yup...program runs even if you do not put "setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );"
in can try it on your machine.:ermm:
+1 Brandon Elliott · July 30, 2014
Your question is a little confusing. Are you saying that your program works the same whether or not you set the default close operation?
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator