Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close box on JFram

Status
Not open for further replies.

grindstonegirl

Technical User
Jun 12, 2003
29
0
0
US
Hi
I have a JFrame and when the user hits the x close box, I want to call a method then close the JFrame. I understand how to use JFrame.EXIT_ON_CLOSE but is there anyway to set it to call a method first? thanks for you help
~grindstone~
 
you can use
Code:
 setDefaultCloseOperation()

Code:
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

if you don't want to do somethings before close your frame
if you must do somethings (e.g. save, change some properties) you must use Window Listener.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top