Click to See Complete Forum and Search --> : How does an application kill itself?


October 7th, 1999, 09:58 AM
Hi. I've written a java program which can be run as either an applet or application (nothing special there ;-))

I have a "close" button on my main window, which I'd like to grey out if it's running as an applet, but enable if running as an application.

If the user presses it while running as an application I'd like to terminate my program immediately.

Q1: I was going to check if it's running as an app or applet by setting a flag in the init and main functions. Is this the best way or is there a runtime function I can call? I would prefer a runtime function.
Q2: How do I tell my application to close immediately? Calling destory does not seem to do anything.

Any help would be gratefully appreciated.

Thanks,

Tom.

poochi
October 7th, 1999, 10:04 AM
> How do I tell my application to close immediately? Calling destory does not seem to do anything.

Call "System.exit(0);"

I dont have answer for your first question. There are lots of complicated solution for your
first question. I will post it later. ( One suggession is , getAncestorParent() and do
toString() with the return value and check what you are getting for both Frame and Applet ).

Poochi

October 7th, 1999, 10:10 AM
Works great!

Thanks a lot.