101 Program to print parameter of Applet in Java

Note:

You cannot print parameter other than String in drawString function of Graphics.

Code:

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;

/*
<applet code="Parameter" height=300 width=200>
<param name="Coding" value="100" /> 
</applet>
*/

public class Parameter extends Applet
{
String name;

public void init()
{
setBackground(Color.red);
name = getParameter("Coding");
}

public void paint(Graphics g)
{
g.drawString("Coding Atharva",25,100);
g.drawString(name,20,10);
}

}


Ouput:

parameter of applet

Previous
Next Post »