Posts

Showing posts from March 20, 2014

Program to demonstrate lifecycle of an applet

import java.applet.Applet;
import java.awt.Graphics;

public class NewApplet extends Applet {


String s=" ";

public void init()
{

s+="init";
}
public void start()
{

s+="start";
}

public void stop()

{

s+="stop";
}


public void destroy()
{

System.out.println("Destroy");
}


public void paint(Graphics g)
{
g.drawString(s,100,100);

}
}

Draw a Rectangle using Applet

import java.applet.Applet;
import java.awt.Graphics;

/**
 *
 * @author a
 */
public class NewApplet extends Applet {



public void paint(Graphics g)
{
g.drawRect(0,0,100,100);

}
}