An Applet Skeleton
Most applets override these four methods. These four methods forms Applet lifecycle.
- init() : init() is the first method to be called. This is where variable are initialized. This method is called only once during the runtime of applet.
- start() : start() method is called after init(). This method is called to restart an applet after it has been stopped.
- stop() : stop() method is called to suspend thread that does not need to run when applet is not visible.
- destroy() : destroy() method is called when your applet needs to be removed completely from memory.
Example of an Applet Skeleton
import java.awt.*; import java.applet.*; public class AppletTest extends Applet { public void init() { //initialization } public void start () { //start or resume execution } public void stop() { //suspend execution { public void destroy() { //perform shutdown activity } public void paint (Graphics g) { //display the content of window } }
No comments:
Post a Comment