I don't know that an applet can exactly terminate itself... Typically this is
controlled by the browser/appletviewer.. When a web page containing an applet
is unloaded the browser should call the stop() method followed by the destroy()
method (when the applets resources are to be reclaimed) of each applet in the
page.. You must override these methods only if you want any special cleanup
done..
destroy() is the opposite of init() which gets called the first time the applet
is loaded.. stop() is the opposite of start() which gets called every time an
applet is accessed again by the browser..
Paul Schroeder
JavaOS Software Engineer
NCSD Division, IBM Corp
512-838-9675
[EMAIL PROTECTED]
[EMAIL PROTECTED] on 13/11/98 06:04:19
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc:
Subject: Two problems.
Hi all,
i am relatively new to Java and i am trying to learn the UI (or
the awt). Below is the code that i compiled ...
-------------------Code begins -------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Buttons extends Applet
{
private Button btnOk, btnExit;
ActionListener myLis_Exit = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
stop();
destroy();
System.exit(0);
}
};
ActionListener myLis_Ok = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.out.println("This is Ok");
}
};
public void init()
{
btnOk = new Button("Ok");
btnExit = new Button("Exit");
btnExit.addActionListener(myLis_Exit);
btnOk.addActionListener(myLis_Ok);
add(btnOk);
add(btnExit);
} //void init();
} //public class Buttons extends Applet
----------------Code Ends----------------------------------
The code compiles ok, but then when i click on the "Exit" in the
appletviewer i get a load of exceptions thrown. If the System.exit() is
commented out, the applet still does not close.
1. how do i terminate an applet?
2. If i click the middle-mouse btn (btn# 3), the appletviewer crashes.
I run RedHat 5.1 on a P2-400.
Thanks,
-Karthik.
+------------------------------------------------------------------------+
| Karthik Vishwanath | National Centre for Biological Sciences|
| [EMAIL PROTECTED] | TIFR Centre, IISc Campus, PO Box 1234 |
| 80-334-5615 or 4062 or 3035 | Bangalore 560012, INDIA |
| Fax 80-334-3851 | |
+------------------------------------------------------------------------+