{{warning}}
请勿使用,浏览器已经不再支持。
{{/warning}}
使用方法
1、编写 HelloWorldApplet.java。
import java.applet.*;
import java.awt.*;
public class HelloWorldApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Hello World!", 25, 50);
}
}
2、将 HelloWorldApplet.java 编译为 HelloWorldApplet.class。
javac .\HelloWorldApplet.java
3、在html中加载 HelloWorldApplet.class。
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<title>Hello World Applet</title>
<link rel="shortcut icon" href="/favicon.ico" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
/>
</head>
<body>
<applet code="HelloWorldApplet.class" width="320" height="120">
If your browser was Java-enabled, a "Hello, World" message would appear here.
</applet>
</body>
</html>