//:APPLET LIFE CYCLE EXAMPLE:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap.class” width=”300″ height=”300″></applet>
*/
public class Ap extends Applet{
public void init(){
System.out.println(“init() called”);
}
public void start(){
System.out.println(“start() called”);
}
public void paint(Graphics g){
System.out.println(“paint() called”);
}
public void stop(){
System.out.println(“stop() called”);
}
public void destroy(){
System.out.println(“destroy() called”);
}
}
//:APPLET CODE-1:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap2.class” width=”300″ height=”300″></applet>
*/
public class Ap2 extends Applet{
public void init(){
//setBackground(Color.red);
setBackground(new Color(100,255,0));
}
public void paint(Graphics g){
g.drawString(“HELLO”,100,100);
g.drawLine(50,50,200,200);
}
}
//:APPLET CODE-2:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap3.class” width=”300″ height=”300″></applet>
*/
public class Ap3 extends Applet{
public void init(){
//setBackground(Color.red);
setBackground(new Color(100,255,0));
}
public void paint(Graphics g){
g.drawRect(50,50,100,200);
g.fillRect(100,100,50,50);
g.drawOval(150,150,200,200);
g.fillOval(200,100,150,50);
}
}
//:APPLET FACE OUTLINE CODE-3:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap4.class” width=”400″ height=”400″></applet>
*/
public class Ap4 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
public void paint(Graphics g){
g.drawOval(20,20,350,350);
g.drawOval(90,120,40,40);
g.drawOval(240,120,40,40);
g.drawOval(170,150,40,140);
g.drawOval(130,310,140,40);
}
}
//:APPLET FILLED FACE CODE-4:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap5.class” width=”400″ height=”400″></applet>
*/
public class Ap5 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
public void paint(Graphics g){
g.setColor(Color.white);
g.fillOval(20,20,350,350);
g.setColor(Color.black);
g.fillOval(90,120,40,40);
g.setColor(Color.blue);
g.fillOval(240,120,40,40);
g.setColor(Color.red);
g.fillOval(170,150,40,140);
g.setColor(Color.green);
g.fillOval(130,310,140,40);
}
}