java Parameter in Applet

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Parameter in Applet

We can get any information from the HTML file as a parameter. For this purpose, Applet class provides a method named getParameter(). Syntax:

  1. public String getParameter(String parameterName)  

Example of using parameter in Applet:

  1. import java.applet.Applet;  
  2. import java.awt.Graphics;  
  3.   
  4. public class UseParam extends Applet{  
  5.   
  6. public void paint(Graphics g){  
  7. String str=getParameter("msg");  
  8. g.drawString(str,5050);  
  9. }  
  10.   
  11. }  

myapplet.html

  

  1.  
  2.  
  3. "UseParam.class" width="300" height="300">  
  4.  value="Welcome to applet">  
  5.   
  6.   
  7.