How do I read an applet parameters?

package org.kodejava.example.applet;

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

public class AppletParameterExample extends Applet {
    private String name = "";

    public void init() {
        // Here we read a parameter named name from the applet tag definition
        // in our html file.
        name = getParameter("name");

    public void paint(Graphics g) {
        g.drawString("Hello " + name + ", Welcome to the Applet World.", 0, 0);

Now we have the applet code ready. To enable the web browser to execute the applet create the following html page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  <title>Parameterized Applet</title>
    <applet code="org.kodejava.example.applet.AppletParameterExample" 
            height="150" width="350">
        <param name="name" value="Mr. Bean" />

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.