java.applet

创建日期:2024-06-21
更新日期:2024-12-18

{{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>

简介

一个来自三线小城市的程序员开发经验总结。