下面的程序中,载入java小应用程序失败,请教大家错在哪里(所加载的java类可以编译和运行,如下的黑体字)?谢谢!!
<%@ page language="java" import="java.awt.*,java.applet.*,java.awt.event.*" %>
<%@ page contentType="text/html;charset=GB2312" %>
<html>
<head>
<title>
烟花
</title>
</head>
<body>
<jsp:plugin type="applet" code="FireTree.class" jreversion="1.4"
width="500" height="200">
<jsp:fallback>
Plugin tag OBJECT or EMBED not supported by browser.
</jsp:fallback>
</jsp:plugin>
<%!
public class FireTree extends Applet implements Runnable
{
final int Max = 1000;
ftparticle p[];
int AppletWidth,AppletHeight,XCenter,YCenter;
Image OffScreen;
Graphics drawOffScreen;
Thread pThread;
public void init()
{
setBackground(Color.black);
p = new ftparticle[Max];
AppletWidth = getSize().width;
AppletHeight = getSize().height;
XCenter = AppletWidth/2;
YCenter = 2*AppletHeight/3;
for(int i=0; i<Max; i++)
p[i] = new ftparticle(XCenter,YCenter);
OffScreen = createImage(AppletWidth,AppletHeight);
drawOffScreen = OffScreen.getGraphics();
}
public void start()
{
pThread = new Thread(this);
pThread.start();
}
public void stop()
{
pThread = null;
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(OffScreen,0,0,this);
}
public void run()
{
int i;
while(true)
{
drawOffScreen.clearRect(0,0,AppletWidth,AppletHeight);
drawOffScreen.setColor(Color.white);
drawOffScreen.fillRect(XCenter,YCenter,5,AppletHeight/3);
for(i=0; i<Max; i++)
{
if(p[i].Y > AppletHeight)
p[i].reset(XCenter,YCenter);
drawOffScreen.setColor(p[i].color);
drawOffScreen.fillOval((int)p[i].X,(int)p[i].Y,3,3);
p[i].X += p[i].Vx;
p[i].Y += p[i].Vy;
p[i].Vy += 9.8*p[i].time/5;
p[i].time++;
}
repaint();
try {
Thread.sleep(200);
}
catch (InterruptedException e) { }
}
}
}
class ftparticle
{
boolean state;
double X,Y;
double Vx,Vy;
int time;
Color color;
public ftparticle(int x,int y)
{
X = x;
Y = y;
reset(x,y);
}
public void reset(int x, int y)
{
X = x;
Y = y;
Vx = (int)(Math.random()*10 - Math.random()*10);
Vy = (int)(-Math.random()*20 - 1);
time = 0;
color = new Color((int)(Math.random()*255),
(int) (Math.random()*255),
(int) (Math.random()*255));
}
}
%>
</body>
</html>