| 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: 19216
|
|
|
The frame closes, but the JVM will continue to run. Just try it from the command line.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1788
|
|
|
Read the JFrame API to see what the default value is for that method. Once you know the default you should understand the behaviour.
|
 |
 |
|
|
subject: swing ques- JFrame
|
|
|