// AppletCar.java //<APPLET code="AppletCar.class" width=220 height=120> // </APPLET> import java.awt.*; import java.applet.*; public class AppletCar extends Applet { public void paint(Graphics g) { g.clearRect(0,20,400,100); g.drawRect(50,60,150,30); g.drawOval(80,90,20,20); g.drawOval(150,90,20,20); g.drawLine(80,60,120,30); g.drawLine(120,30,170,30); g.drawLine(170,30,190,60); g.drawString("Hello",120,80); } }これをコンパイルし, 次のように,appletとしてtest.htmlファイルの中に記述しておき,
<APPLET code="AppletCar.class" width=220 height=120> </APPLET>appletviewerによって,
% appletviewer test.html実行すると, 次のような絵が表示される.