• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

swing ques- JFrame

 
RajivAwadhesh kumar
Greenhorn
Posts: 24
  • 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
  • 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: 20611
63
Chrome Eclipse IDE Java Windows
  • 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: 2613
9
  • 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