<applet> (<applet code=”app.class” height=500 width=500>)tag is used to pass parameter in an applet. We use <PARAM> tag to pass anapplet parameters. The <PARAM> (<PARAM NAME= firstname VALUE=”REKHA”>)tag has two attributes one is NAME and other is VALUE.
<Param> tag Example in Java
import java.awt.*;
import java.applet.*;
public class app extends Applet
{
String firstn,lastn,sex,add,city,phone,email;
Font f1,f2;
public void init()
{
f1=new Font(“Arial”,Font.PLAIN,16);
f2=new Font(“Arial”,Font.BOLD,20);
}
public void start()
{
firstn=getParameter(“firstName”);
if(firstn==null)
firstn=”Not Found”;
lastn=getParameter(“lastName”);
if(lastn==null)
lastn=”Not Found”;
sex=getParameter(“sex”);
if(sex==null)
sex=”Not Found”;
add=getParameter(“add”);
if(add==null)
add=”Not Found”;
city=getParameter(“city”);
if(city==null)
city=”Not Found”;
phone=getParameter(“phone”);
if(phone==null)
phone=”Not Found”;
email=getParameter(“email”);
if(email==null)
email=”Not Found”;
}
public void paint(Graphics g)
{
g.setFont(f2);
g.drawString(“-:Detail Information about User :- “, 75,20);
g.setFont(f1);
g.drawString(” First Name of the user:”+firstn,5,60);
g.drawString(” Last Name of the user:”+lastn,5,80);
g.drawString(“Sex:”+sex,5,100);
g.drawString(“Address:”+add,5,120);
g.drawString(“City:”+city,5,140);
g.drawString(“Contact no:”+phone,5,160);
g.drawString(“Email:”+email,5,180);
}}
/*<applet code=”app.class” height=500 width=500>
<PARAM NAME= firstname VALUE=”REKHA”>
<PARAM NAME= lastname VALUE=”SETIA”>
<PARAM NAME= sex VALUE=”FEMALE”>
<PARAM NAME= add VALUE=”A=CIVIL”>
<PARAM NAME= city VALUE=”PUNJAB”>
<PARAM NAME= phone VALUE=”9876553500″>
<PARAM NAME= email VALUE=”rekhasetia2011@gmail.com”>
</applet>
*/
Explanation….
In the above example, the user information is passed as a parameter of the <PARAM> tag. The gerParameter()retrieves the value of each parameter and displays this value on an applet. We can use <PARAM> tag in HTML document. When you are working with the <PARAM>tag, you can change the contents that are displayed on an applet by changing the parameter values in the HTML file.