package org.kodejava.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.setColor(Color.BLUE);
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>
<html lang="en">
<head>
<title>Parameterized Applet</title>
</head>
<body>
<applet code="org.kodejava.applet.AppletParameterExample"
height="150" width="350">
<param name="name" value="Mr. Bean"/>
</applet>
</body>
</html>
** Deprecated: The Applet API is deprecated since JDK 9, no replacement.
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024