Applet Life Cycle Assignment Help

Assignment Help: >> Applet Life Cycle - Applet Life Cycle

Applet Life Cycle:

All but the most trivial applets override a set of methods which gives the basic mechanism through that the browser or applet viewer interfaces to the applet and controls its execution. Four of these method - init (), stop (), start (), and destroy () - are defined by Applet. An additional, paint (), is defined through the AWT Component Class. Default implementations for all of these methods are given. Applets do not require overriding those methods they do not use. Thus, only very simple applets will not require defining all of them. These five methods could be assembled into the skeleton display here:

// An Applet Skeleton.

import java.awt.*;

import java.applet.*;

/*

<applet code = "AppletSkel " width = 300 height =100>

</applet>

*/

public class AppletSkel extends Applet{

//Called first.

Public void init(){

// initialization

}

/* Called second, after init() . Also called whenever the applet is restarted .*/

public void start(){

//start or resume execution

}

//Called when the applet is stopped.

Public void stop (){

//suspends execution

}

/* Called whenever applet is terminated. This is the final method executed.*/

public void destroy () {

// perform shutdown activites

}

//Called whenever an applet's window must be restored.

Public void paint (Graphics g){

//redisplay contents of window

}

}

Although this skeleton does not do anything, it can be compiled and run. Whenever run, it produces the following window whenever viewed along with an applet viewer.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd