Androidberry logo Androidberry text logo
AndroidBerry Home
  • Learn Java
  • Java Programs
  • Interview Questions
  • Androidberry facebook
  • Androidberry twitter
  • Androidberry google plus

Java Tutorials


Basic Introduction

Decision Making

Looping

Classes and Objects

Inheritance

Interface

Packages

Exception Handling

Multithreading

Java Multithreading
Creating a Thread
Thread Life Cycle
Thread Exceptions
Thread Synchronization

Java Applets

What is Applet?
Java Applet vs Application
Creating a Applet
Displaying Applet on Webpage
Applet Lifecycle
Applet Tag
Passing Parameters to Applet
Setting Color to applet
Update and Repaint method
Using Fonts in Applet

Graphics Programming

Intro. to Graphics class
Drawing - Lines , Rectangles
Drawing - Circles and Ellipse
Drawing - Arcs
Drawing - Polygons
Drawing - Bar Charts

More on Java

Java Programs
Java Keywords Dictionary
Java Interview Questions

Java Applet Parameter Passing


Param Tag Java

Java applet allows us to pass user defined parameters using <applet > Tag.

What is PARAM Tag

  • Param tag is used to handle parameters passed to an html document.
  • Param tag has 2 parameters - Name and value. where Name is the user defined name like variables and value is the value to be stored into the name.
  • Param tag is written within the applet tag in comment section.
  • When applet is loading the getParameter() method is used inside the init() method to access the parameters of param tag.
  • The parameters are in string type, we need to typecast them if values are other than string type.
  • We can write any number of param tags inside applet tag get parameters of different type.

Syntax

/* <applet code="AppletName.class" width=300 height=300>
    <param name="param1" value="value1">
    <param name="param2" value ="value2">
    ...
    ...
</applet> */

Example

Program to display message using param tag

/* <applet code="Test.class" width=300 height=300>
    <param name="param1" value="Hello. I'm Applet">
</applet> */

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

public class Test extends Applet
{
    String s=null;
    public void init()
    {
	s = getParameter("val");
    }
    public void paint(Graphics g)
    {
	g.drawString(s, 15, 140);
    }
}

Output

<< Previous Next >>

See Also

All Java Programs
Java Keywords
Java Interview Questions

AndroidBerry Support

About us
Contact us
Suggest us
Questions?

Follow us

Androidberry FacebookFacebook
Androidberry TwitterTwitter
Androidberry GooglePlusGoogle+
Back to top
Androidberry Name Logo