| Back |
|
What is applet? Applet is a java application that is embedded (and is running) in the browser such as Internet Explorer or Netscape. An applet program must extends the Applet class. When you write an applet, it should start like this: class Demo extends Applet And because the Applet class is in the java.applet package, you must also import this package. import java.applet.*;
class Demo extends Applet
Applet has several methods that are reffered to as milestones.
They are called milestones because they indicate an action that
happens during the applet's lifecycle. These methods are defined
in the Applet class, and when you are writing an applets you may
overrides them. Who is actually invokes those methods? The answer
is the browser where the applet is running. Or, more accurate, is
the application that runs the applets will invokes those
milestones methods. The browser is one of this application, and
other's can be appletviewer. I don't know any other applications
that can run or embed applet inside them. What are the milestones methods? These methods are declared in the Applet class as ... public void init() { }
public void start() { }
public void stop() { }
public void destroy() { }
When an applet is loaded inside the browser, the init()
method is called, then the start() method is called. When
you closes the browser window, or leaves the applet page, the
stop() method is called. And, before the applet is
unloading, the destory() method is called.
|
< PENDING >