Link to home
Start Free TrialLog in
Avatar of deniX23
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.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

What would be wrong with dispose btw?
Avatar of deniX23
deniX23

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.
>>the user didnt set EXIT_ON_CLOSE

Isn't it you the programmer who's setting that, not the user?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deniX23

ASKER

By user i meant another programmer using my frame class.
Anyway, thanks objects that's pretty much equivalent to what i needed.