You are here: Home / Topics / Program 2 to create Applet with param tag in Java

Program 2 to create Applet with param tag in Java

Filed under: Java on 2023-09-20 06:41:28

//  Program to create Applet with param tag.

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

/*
<applet  code="AppletTest3.class" width="300" height="60">
<param name="msg" value="Let's learn Applet.">  
</applet>
*/

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

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

public void paint( Graphics g ) 
{
 System.out.println(msg);
 g.drawString(msg, 50, 30);
}
}

HTML Source Code [ AppletTest3.html ] : 
<html>  
<head>  
 <title>BIIT</title>  
</head>
 
<body>
 <applet code="AppletTest3.class" width="300" height="60">  
  <param name="msg" value="Let's learn Applet.">  
 </applet>  
 <hr size="4">  
</body>  
</html>

 

Output:

D:\Java>appletviewer AppletTest3.java 
Let's Learn Applet.

D:\Java>appletviewer AppletTest3.html 
Let's Learn Applet.

About Author:
M
Mr. Dubey     View Profile
Founder and CEO of MCQ Buddy. I just like to help others.