File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

swing ques- JFrame

 
RajivAwadhesh kumar
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I tried a swing program from HeadFirst Java which is as following..



Its written in the book that if we use frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
the program will quit as soon as we close the window(if we leave this out
it will just sit there on the screen forever).

But when i dont use the above line the program closes as well , when i click the close button.
So whats the use of the above code line?
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you recompile? Because what the book says is correct.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The frame closes, but the JVM will continue to run. Just try it from the command line.
 
Rob Camick
Ranch Hand
Posts: 2473
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the JFrame API to see what the default value is for that method. Once you know the default you should understand the behaviour.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic