Java Applet不在HTML中显示

时间:2015-10-16 14:14:51

标签: java applet

这是我的小程序。它完美地运作。它显示applet中的所有内容。

import java.applet.Applet;   // Imports the Applet class
import java.awt.Graphics;    // Imports the Graphics class, used to draw lines, circles, squares, text, etc

/** 
* The HelloWorldApplet class implements an applet that simply displays "Hello World!". 
*/ 

// Our HelloWorldApplet class extends  the Applet class, giving it access to all the methods of Applet.
public class HelloWorldApplet extends Applet
{         

// The paint method draws anything that is in our applet on the applet screen.  
// It takes a graphics object (g), that is used to draw

public void paint(Graphics screen) 
{     
    // drawString is a method of the Graphics class.  It takes a string, and two integer parameters 
    // as x and y coordinates.  These coordinates correspond to Quadrant I of a traditional coordinate
    // plane, so they are always positive.         
    screen.drawString("Hello World Applet", 50, 30);
    screen.drawString("Sikki Nixx", 50, 60);
    screen.drawString("What was yesterday's date?", 50, 90);
    screen.drawString(printAmerican(), 50, 120);
}

public String printAmerican() {
    return ("Thursday" + ", " + "October" + " " + 15 + ", " + 2015 + ".");
}
}

这就是我对HTML的看法,但网页上没有任何内容。任何人都可以帮我解决这个问题吗?

<HTML>
<BODY>
<APPLET CODE=HelloWorldApplet.class WIDTH=200 HEIGHT=100>
</APPLET>
</BODY>
</HTML>

0 个答案:

没有答案