• Post Reply Bookmark Topic Watch Topic
  • New Topic

frames

 
Dave Kairys
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the reason for the code that follows:
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);?
If that is not put in the app, will the frame continue to exist in the JVM or elsewhere?

Thanks,
Dave
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, closing a Frame just gets rid of that one Frame, and the program keeps running. This is a good default in an application where they may be multiple Frames. But in an application where there will only ever be one Frame, it makes sense to exit the JVM altogether (i.e., quit the program) when the Frame is closed. That's what this does.
 
Nicholas Carrier
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also if you don't have it in there, you'd need to find another way to exit your program. For example if your in the command screen you'll have to hit ctrl+c to exit the program.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!