aspose file tools*
The moose likes Beginning Java and the fly likes swing ques- JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "swing ques- JFrame" Watch "swing ques- JFrame" New topic
Author

swing ques- JFrame

RajivAwadhesh kumar
Greenhorn

Joined: May 20, 2011
Posts: 24
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

Joined: Oct 25, 2008
Posts: 2700

Did you recompile? Because what the book says is correct.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

The frame closes, but the JVM will continue to run. Just try it from the command line.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
Read the JFrame API to see what the default value is for that method. Once you know the default you should understand the behaviour.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: swing ques- JFrame