Home | Java Menu | Java Applets | Java Tips | E-mail Us
Java Applets
Date and time
Image animation
Window status message on mouse over images
Using the <PARAM> tag to collect user arguments
Graphical User Interface (GUI) - buttons, labels, checkboxes, and text areas
Multimedia using sound
Multimedia using image
Application and Applet combined
Running threads
Using the <PARAM> tag to collect user argumentsUsing the <PARAM> tag to collect user arguments

To pass parameters to an applet, the parameters must be declared before the applet starts. They also must be read by the applet when the applet is initialized. The parameters are declared using the <PARAM> tag in the HTML page which is embedded in the <APPLET> tag, and it has no end tag.

The syntax for the <PARAM> tag is as follows:
<PARAM NAME=parametername VALUE=parametervalue>

The HTML source file might look like the following:


<HTML>
<HEAD>
<TITLE>Passing Parameters Example</TITLE>
</HEAD>
<APPLET CODE="MyProgram.class" WIDTH="200" HEIGHT="300">
    <PARAM NAME="message" VALUE="My first Java applet">
    <PARAM NAME="imagefile" VALUE="picture.jpg">
</APPLET>
</BODY>
</HTML>
To read the parameter from the applet, use the following method:
public String getParameter("parametername");

Sample applets using the <PARAM> tags:
  • Multimedia using sound
  • Multimedia using image
Home | Java Menu | Java Applets | Java Tips | Legal
© 1999-2003 Complete e Solutions, Inc.