|
| | Here lies an applet:
(You can't see it, because it has a width and height of 0.)
This applet should display a message dialog box telling you when:
- It initializes
- It starts
- It stops
- It is destroyed
By now, you perhaps have already seen the first two dialog boxes, and
dismissed them. Ideally, when you move away from this page, you should
then see another dialog box indicating that the applet is stopping.
However, for reasons unknown, you may find that this dialog comes up, does not
completely paint, and it, and the entire browser hangs.
Here is the code for this applet:
package applets;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
public class AppletLife extends JApplet
{
public void init()
{
JOptionPane.showMessageDialog(this, "I am initializing", null,
JOptionPane.INFORMATION_MESSAGE);
}
public void start()
{
JOptionPane.showMessageDialog(this, "I am starting", null,
JOptionPane.INFORMATION_MESSAGE);
}
public void stop()
{
JOptionPane.showMessageDialog(this, "I am stopping", null,
JOptionPane.INFORMATION_MESSAGE);
}
public void destroy()
{
JOptionPane.showMessageDialog(this, "I am being destroyed", null,
JOptionPane.INFORMATION_MESSAGE);
}
}
|
|