Java- Basic Applet Example

// A simple Applet

//init(),start(),stop() and destroy() are available in Applet class
// paint() method is available in component class //Object->awt->Component

//program starts from here

import java.applet.Applet;
import java.awt.Graphics;
//To run applet in appletviewer
<applet  code=AppletEx1  width=200 height=200 >

public class AppletEx1 extends Applet

String msg;

public void init()       // to initialize
setForeground(;//whatever we draw on screen

msg="Inside init";
public void start()    //to run Applet
msg=msg+"   "+"Inside start";
public void paint(Graphics g)//Object->awt->Graphics to output on Applet
msg=msg+"   "+"Inside paint";