How to close java Applet through code

后端 未结 4 1929
失恋的感觉
失恋的感觉 2021-01-22 02:52

I am developing a java applet. I want it to be closed by the code. I have used System.Exit(0) but it is not working. Is there any other method to achieve this?

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-22 03:14

    applet.getAppletContext().showDocument("ThanksForUsingOurApplet.html");
    

    As to the comment that a signed applet can call System.exit(n).

    It can in some browser/JRE combos., it can't in others. In the ones that it can, it shouldn't since an applet may share a VM with other applets (less common these days), and even if not, it is the user's responsibility to close an applet by closing the page.

    An applet is a guest in a web page. Calling System.exit(n) is like burning down the guest house.

提交回复
热议问题