如何关闭按钮点击applet

时间:2012-11-22 13:19:29

标签: java applet

如何从代码中关闭applet 我使用过 System.exit(0)但它只抛出一堆异常并且没有关闭它。 我知道用户有责任关闭applet,但仍然有办法吗?

2 个答案:

答案 0 :(得分:3)

不要在applet中调用System.exit(0)。这可能导致浏览器关闭。

更好的方法是在JFrame中运行应用程序并使用Java Web Start启动应用程序。

答案 1 :(得分:2)

actionPerformed(ActionEvent)方法中,请致电..

// end the applet by navigating to the 'applet ended' URL
applet.getAppletContext().showDocument(appletCloseURL);
相关问题