ALIGN  ALIGN is an optional attribute that specifies the alignment of the applet. This
attribute is treated the same as the HTML IMG tag with these possible values: LEFT, RIGHT,
VSPACE and HSPACE  These attributes are optional. VSPACE specifies the space, in pixels,
above and below the applet. HSPACE specifies the space, in pixels, on each side of the applet.
They're treated the same as the IMG tag's VSPACE and HSPACE attributes.
PARAM NAME and VALUE  The PARAM tag allows you to specify applet-specific arguments
in an HTML page. Applets access their attributes with the getParameter( ) method.
Other valid APPLET attributes include ARCHIVE, which lets you specify one or more
archive files, and OBJECT, which specifies a saved version of the applet. In general, an
APPLET tag should include only a CODE or an OBJECT attribute, but not both.
Passing Parameters to Applets
As just discussed, the APPLET tag in HTML allows you to pass parameters to your applet.
To retrieve a parameter, use the getParameter( ) method. It returns the value of the specified
parameter in the form of a String object. Thus, for numeric and boolean values, you will
need to convert their string representations into their internal formats. Here is an example
that demonstrates passing parameters:
// Use Parameters
import java.awt.*;
import java.applet.*;
<applet code="ParamDemo" width=300 height=80>
<param name=fontName value=Courier>
<param name=fontSize value=14>
<param name=leading value=2>
<param name=accountEnabled value=true>
public class ParamDemo extends Applet{
String fontName;
int fontSize;
float leading;
boolean active;
// Initialize the string to be displayed.
public void start() {
String param;
fontName = getParameter("fontName");
if(fontName == null)
fontName = "Not Found";
param = getParameter("fontSize");
try {
if(param != null) // if not found
fontSize = Integer.parseInt(param);
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks