• Post Reply Bookmark Topic Watch Topic
  • New Topic

Program not ending properly

 
Joe Lemmer
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I have made a little program that (so far) just makes a GUI appear. I run the program from the command line using 'java Blah'.

When I get rid of the GUI however the Command Prompt doesn't have the cursor on a nice fresh new line waiting for instructions, but rather just flashes away as if the program is still running. So, I have to shut the command prompt down and start up a new one.

Not a massive problem, but I wonder if anyone might know why this could be happening.

All help gratefully received!

Cheers

Joe
 
Campbell Ritchie
Marshal
Posts: 52608
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a JFrame? Go through the JFrame API and you find out what happens when a JFrame closes. It gives you hints about how to sort it out. Tell us how you get on

And I think I ought to move this thread to the Swing forum.
 
Joe Lemmer
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell.

I've used the setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) method and everything is sorted.

Thanks for the help.

Cheers

Joe
 
Campbell Ritchie
Marshal
Posts: 52608
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

EXIT_ON_CLOSE works for simple apps, but for something complicated you are better off with a WindowListener, then you can put calls to "Your file has changed, do you wish to save it?" in the windowClosed or windowClosing methods.
 
Joe Lemmer
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent. I'll have to look into that that sounds useful.

Thanks again. ;-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!