You are here: Home / Topics / Program to use Applet Program and it's Life Cycle in Java

Program to use Applet Program and it's Life Cycle in Java

Filed under: Java on 2023-09-20 06:34:59

// Program to use Applet Program and it's Life Cycle.

import java.awt.*;
import java.applet.*;

/*
<applet code="Applet01" width="300" height="200">
</applet>
*/

public class  Applet01  extends  Applet 
{
public void init() 
{
 setBackground(Color.yellow);
 System.out.println("init() called.");
}

public void start() 
{
 System.out.println("start() called.");
}

public void stop() 
{
 System.out.println("stop() called.");
}

public void destroy() 
{
 System.out.println("destroy() called.");
}

public void paint(Graphics g) 
{
 System.out.println("paint() called.");
 g.drawString("Java Programming Examples", 50, 100);
}
}


Output:

D:\Java>appletviewer Applet01.java  

init() called.
start() called.
paint() called.
stop() called.
start() called.
paint() called.
stop() called.
destroy() called.

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.