Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

(JFrame.EXIT_ON_CLOSE) programmatically.  RSS feed

 
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
Is there a way to exit a JFrame programmatically without clicking on the X In the window.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15858
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call setVisible(false) on the JFrame so that it is not visible anymore on screen. If you want to exit the application, you can call System.exit(...).
 
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying
System.exit(..) Is the only thing that works for me so far but I was curious as to whether this Is a sloppy way to clear things up.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also call dispose() on the JFrame.
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But dispose() is different from System.exit();

They used to have to add listeners in AWT, rather like this:


[Edit]Moving to our GUIs forum[/edit]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!