Mr_Hmp
Mr_Hmp

Reputation: 2535

how to close applet on button click

How to close applet from code I have used System.exit(0) but it only throws bunch of exceptions and it did not closes it. I understand that it is responsibility of the user to close applet , but still is there any way?

Upvotes: 2

Views: 6868

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168825

In the actionPerformed(ActionEvent) method, call..

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

Upvotes: 2

Reimeus
Reimeus

Reputation: 159784

Don't call System.exit(0) in an applet. This can cause the browser to be closed.

A better approach would be to run application in a JFrame and use Java Web Start to launch the application.

Upvotes: 3

Related Questions