Java试用(2)applets, 嵌入在网页中的ui.

程序

import java.awt.*;

import java.applet.*;

public class HelloWorldApplet extends Applet { //an applet

    public void paint(Graphics g){

    g.drawString ("Hello World!",20,20);

    }

}

网页

<HTML>

<HEAD>

<TITLE> An Applet </TITLE>

</HEAD>

<BODY>

<applet code="HelloWorldApplet.class" width=200 height=40>

</applet>

</BODY>

</HTML>

编译

 javac HelloWorldApplet.java

 

执行:

用ie打开网页即可

Powered by Jekyll and Theme by solid

本站总访问量