Because applets are run from browsers, they differ from applications in that they do not have a main method. Instead, applets have an init method that is used to perform any applet initialization and is called only once in the lifetime of an applet.
The first method the Web browser invokes on loading the applet is the constructor. In MultiplyApplet, we could have overridden the MultiplyApplet constructor to perform some applet initialization. However, it is not always possible to perform all initialization within an applet constructor. For this reason, the applet class provides the init method, which is invoked after the applet object has been created.
The start method is invoked immediately after the init method. start, as the name suggests, starts the applet execution. start is also invoked if the user revisits the page containing the applet, having left it to visit other Web pages.
The stop method is used to stop the applet's execution, and is invoked when the user quits the browser or leaves the applet's page to visit other Web pages.
The destroy method is invoked after the stop method when the user quits the browser. The applet is unloaded, and any final cleanup actions, such as freeing up memory, are performed by this method.
Note that all these methods belong to the Applet class, and are inherited by the JApplet class, and so apply to both Swing and AWT applets.
The first method the Web browser invokes on loading the applet is the constructor. In MultiplyApplet, we could have overridden the MultiplyApplet constructor to perform some applet initialization. However, it is not always possible to perform all initialization within an applet constructor. For this reason, the applet class provides the init method, which is invoked after the applet object has been created.
The start method is invoked immediately after the init method. start, as the name suggests, starts the applet execution. start is also invoked if the user revisits the page containing the applet, having left it to visit other Web pages.
The stop method is used to stop the applet's execution, and is invoked when the user quits the browser or leaves the applet's page to visit other Web pages.
The destroy method is invoked after the stop method when the user quits the browser. The applet is unloaded, and any final cleanup actions, such as freeing up memory, are performed by this method.
Note that all these methods belong to the Applet class, and are inherited by the JApplet class, and so apply to both Swing and AWT applets.
No comments:
Post a Comment