You are here: Home / Topics / Program to use Applet with init(), start() and paint() in Java

Program to use Applet with init(), start() and paint() in Java

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

// Program to use Applet with init(), start() and paint().

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

/*
<applet  code="AppletTest1.class" width="300" height="100">
</applet>
*/

public class AppletTest1 extends  Applet 
{
String msg = "";

public void init() 
{
 setBackground( Color.yellow );
 msg = "init() ->";
}

public void start() 
{
 msg += "start() ->";
}

public void paint( Graphics g ) 
{
 msg += "paint() ->";
 g.drawString(msg, 50, 50);
}
}


Output:

D:\Java>appletviewer AppletTest1.java


About Author:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.