import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class FootBall extends Applet implements MouseListener,Runnable
{
int x,y;
public void init()
{
x=0;
y=0;
setBackground(Color.light);
addMouseListener(this);
}
public void paint(Graphics g)
{
}
public static void main(String args[]){
FootBall applet=new FootBall();
JFrame frame=new JFrame("Crazy FootBall");
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
frame.getContentPane().add(
applet,BorderLayout.CENTER);
frame.seSize(1024,768);
applet.init();
applet.start();
frame.setVisible(true);
}
public void run()
{
Graphics g1;
g1 = getGraphics();
int x1,y1,m1,m2,m3,l2,v=3;
double x2,y2,l1;
x1=x;
y1=y;
m1=x1;
m2=y1;
m3=x1*x1+y1*y1;
m3=(double)m3;
m3=Math.sqrt(m3);
x2=(0.1*x1)/m3;
y2=(0.1*y1)/m3;
l1=(x1+y1)*10*0.1;
l2=(x1+y1)*10;
l1=(int)l1;
for(int i=1;i<=l2;i++)
{
g1.setColor(Color.red);
g1.drawOval(x2,y2,32,32);
g1.setColor(Color.white);
}
try
{
Thread.CurrentThread().sleep(200);
}
catch(InterruptedException e){}
}
}
public void mousePressed(MouseEvent e)
{
x = e.getX();
y = e.getY();
Thread one;
one = new Thread(this);
one.start();
one = null;
}
}
总是报这个错误
![]()