The Artima Developer Community
Sponsored Link

Java Answers Forum
exit function in frames

3 replies on 1 page. Most recent reply: Jun 10, 2002 12:31 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
jake

Posts: 83
Nickname: onorok
Registered: May, 2002

exit function in frames Posted: Jun 9, 2002 10:04 PM
Reply to this message Reply
Advertisement
Ok, I am trying to make and exit button in my frame. So what I have right now is, every time the user presses the exit button, I say, "System.exit(0);"
and it closes the frame but not the dos window. How can I make it close both the frame and the dos window?


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: exit function in frames Posted: Jun 10, 2002 12:41 AM
Reply to this message Reply
That depends on how the DOS window was opened. If you are launching it with a batch file that the user-double clicks and the batch contains something like this:

@echo off
cd "program directory"
java ProgramName

Then all you have to do is add the cls command as the last line and the DOS box will disappear after the program exits.

On the other hand, if you are using a shortcut, or lnk file, then right-click on it, choose Properties find the Close on Exit checkbox on the Program tab and check it.

If the DOS box was already open and you run your program by typing in the java command line or a batch file name, then you can either add "exit" to the end of the batch file, or type Ctrl-T then "exit" on the command line after the java command (assuming you are running DosKey, as any rational person should).

Finally, unless you want to see console output (it can be handy for debug and stack trace output of unhandle exceptions (not that I'm implying you would have any of those :-)), you could be running your app with javaw instead of java and there will be no unsightly DOS box to deal with in the first place. Hmm, come to think of it, you could run under Linux and you wouldn't have a DOS box...

jake

Posts: 83
Nickname: onorok
Registered: May, 2002

Re: exit function in frames Posted: Jun 10, 2002 11:39 AM
Reply to this message Reply
I am running the application from Jcreator (IDE) and everytime I run the program it opens a dos window with my JFrame. I just want to be able to hit the exit button in my JFrame and have everything close.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: exit function in frames Posted: Jun 10, 2002 12:31 PM
Reply to this message Reply
I haven't used JCreator, but unless it is a complete piece of junk, I'm sure you can tweak the settings to have it run javaw.exe instead of java.exe to execute programs. They might even have a "close DOS box on exit" configuration option. If they don't have these, then it is high time to switched to a better IDE, like IntelliJ's IDEA, or Borland's JBuilder!

I suspect it works the way it does on purpose though; if your program had output information to the console, you would want to see it, rather than have it disappear immediately.

Flat View: This topic has 3 replies on 1 page
Topic: Interface transitions Previous Topic   Next Topic Topic: ON-LINE PROGRAM

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use