Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing a JFrame without using WindowEvent  RSS feed

 
a gandhi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am just wondering if we can close a frame without using addWindowListener. I just want the frame to be closed without clicking on the X mark of the frame. I tried setVisible(false) but it just makes the frame invisible but it's still running, I want the application to be closed. If there is a way or any suggestions please let me now .
Thanks..
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use
System.exit (0);
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eddie Vanda:
You could use
System.exit (0);

This works if you need to terminate your main() method. If you just need to close a JFrame but still need your app running, be sure and use
frame.dispose();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!