deniX23
asked on
Closing a JFrame window
Hi,
I have a JFrame window. Is there any command that closes the window, (not hide() or dispose()), a command that is equivalent to the user pressing the top right 'X' button.
I have a JFrame window. Is there any command that closes the window, (not hide() or dispose()), a command that is equivalent to the user pressing the top right 'X' button.
What would be wrong with dispose btw?
ASKER
In the window i have a menu with "close" in it and i want it to act like the top right "X" button:
If the person creating the window uses setDefaultCloseOperation with paramater EXIT_ON_CLOSE, then using "dispose()" when the user clicks "close" won't work (because it won't do the "exit on close" like the "X" would of), on the other hand i can't do system.exit() when the user clicks "close" because maybe the user didnt set EXIT_ON_CLOSE, i cant assume he did or didnt.
If the person creating the window uses setDefaultCloseOperation with paramater EXIT_ON_CLOSE, then using "dispose()" when the user clicks "close" won't work (because it won't do the "exit on close" like the "X" would of), on the other hand i can't do system.exit() when the user clicks "close" because maybe the user didnt set EXIT_ON_CLOSE, i cant assume he did or didnt.
>>the user didnt set EXIT_ON_CLOSE
Isn't it you the programmer who's setting that, not the user?
Isn't it you the programmer who's setting that, not the user?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
By user i meant another programmer using my frame class.
Anyway, thanks objects that's pretty much equivalent to what i needed.
Anyway, thanks objects that's pretty much equivalent to what i needed.
:)