I have a single frame created using Netbeans GUI builder when I view the frame properties one of the first options is default close operation the options listed are: DISPOSE_ON_CLOSE
, HIDE_ON_CLOSE
, DO_NOTHING_ON_CLOSE
& EXIT_ON_CLOSE
I understand the middle two but, whats the difference between DISPOSE_ON_CLOSE
and EXIT_ON_CLOSE
? I have tried testing both but to me they do the same thing to me
Asked
Active
Viewed 3.4k times
12

Lukas Rotter
- 4,158
- 1
- 15
- 35

Ayvadia
- 339
- 1
- 4
- 19
3 Answers
15
EXIT_ON_CLOSE
will terminate the program.
DISPOSE_ON_CLOSE
will call dispose()
on the frame, which will make it disappear and remove the resources it is using. You cannot bring it back, unlike hiding it.
See aslo JFrame.dispose() vs System.exit()

Community
- 1
- 1

Garrett Hall
- 29,524
- 10
- 61
- 76
-
It removes the resources it is using. You cannot bring it back, unlike hiding it. – Garrett Hall Oct 17 '13 at 17:33
2
DISPOSE_ON_CLOSE - Disposes the window when it's closed. You cannot redisplay the window, although the object window is still available in the memory

Palak Kharbanda
- 183
- 8
-
1"although the object window is still available in the memory".=> it still *uses* memory (until it is garbage collected). Saying it is "available" is confusing at least. And yet another thing: you *can* redisplay the window, though it will require recreating it (using the `new` keyword). – Alain BECKER Mar 31 '21 at 16:39