I have an Exit button in an applet and the applet should exit when the user clicks on the exit button. I tried using System.exit(), but it throws Exception.
I am not sure that you want to try and stop the VM. Another way would be to send the browser to a different page when the exit button is hit. Therefore sopping the applet. Nathan
That's what I have done as a temporary solution. It would be better if I can exit the VM, just like when a System.exit() is called from a window closing event.
hi import java.awt.event.*; import java.applet.Applet; import java.awt.*; class demo extends Applet implements ActionListener { public void init(){ Button B1=new Button("rahul"); add(B1); B1.addActionListener(this);} public void actionPerformed(ActionEvent e) {System.exit(0); }
} i tried the above . when the button is pressed the action event System.exit is taking place. however there is a runtime Security excepiton being raised in the console window. Regds. Rahul.
[This message has been edited by rahul_mkar (edited June 21, 2000).]
hi sunitha & rahul it will raise an exception called runtimeexception . u have to exit vm to exit from the applet. for that u have to grant permission using policytool. from the dos prompt enter policytool. in that window add permission called runtime & target as exitvm save the file with extension .pol.come out & run the applet as appletviewer -J-Djava.seurity.policy="filename.pol" appletfilename it will work.thanks
Iam not sure whether System.exit() will work when the Applet is embedded in a web-browser because ur trying to close the applet which is in turn embedded in a another container of the web-browser.And the web-browser will always have a window.The other way is to navigate to an another page there by stopping the Applet execution
You can't use System.exit() without raising a security exception. What you can do is call the applet destroy() method from the applet's stop(). So, create a stop() method which does any cleanup and calls destroy(). Then call stop() from your actionPerformed(). [This message has been edited by Glen Tanner (edited August 04, 2000).] [This message has been edited by Glen Tanner (edited August 04, 2000).]
Don't get me started about those stupid light bulbs.