import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class c2_1 extends Applet implements Runnable
{
Thread thisThread;
float x;
float y;
float a;
float q;
float t;
int i;
public void stop()
{
thisThread.stop();
}
public void paint(Graphics g)
{
if(i > 10)
{
g.setColor(Color.red.darker());
g.fillRect(0, 0, 230, 310);
g.setColor(Color.white);
a = q * (float)i * t;
x = (float)(120D - 200D * Math.sin(a));
y = (float)(300D - 200D * Math.cos(a));
g.drawString("r0", (int)(x - 15F), (int)(y + 10F));
g.drawString("r0", 130, 100);
g.drawString("Java学件:单位矢量的微分", 40, 20);
g.drawString("点击鼠标左键控制暂停和运行", 40, 55); }
if(i < 20) {
g.drawString("dr0", (int)(0.90000000000000002D * (double)x + 10D), (int)(0.90000000000000002D * (double)y));
g.setColor(Color.white);
g.drawLine(120, 300, 120, 100);
g.drawLine(120, 300, (int)x, (int)y);
g.setColor(Color.green);
g.drawLine(120, 100, (int)x, (int)y);
g.drawLine((int)x, (int)y, (int)((double)x + 10D * Math.cos((double)a + 0.10000000000000001D)), (int)((double)y - 10D * Math.sin((double)a + 0.10000000000000001D)));
g.drawLine((int)x, (int)y, (int)((double)x + 10D * Math.cos((double)a - 0.10000000000000001D)), (int)((double)y + 10D * Math.sin((double)a - 0.10000000000000001D)));
i--;
}
}
public c2_1()
{
q = 0.1F;
t = 0.1F;
i = 40;
}
public void update(Graphics g)
{
paint(g);
}
public void start()
{
thisThread = new Thread(this);
thisThread.start();
}
public void run()
{
do
{
repaint();
try
{
Thread.sleep(1000L);
}
catch(Exception e) { }
}while(true);
}
public void init()
{
addMouseListener(new MouseAdapter())
{
public void mouseClicked(MouseEvent e)
{
if(thisThread.isAlive())
stop();
else
start();
}
{
(this.this$0 = c2_1.this).getClass() ;
}
}
}
}
我编译了,然后上面说少了一个;还有(this.this$0 = c2_1.this).getClass() ;这句话也不知道对不对 。楼主能不能告诉我一下静态this怎么用?