标题:[求助]静态this怎么用?
只看楼主
xiexiaoqiang
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-2-26
 问题点数:0 回复次数:1 
[求助]静态this怎么用?

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怎么用?

搜索更多相关主题的帖子: float 静态 import awt java 
2006-03-03 19:32
zhouyao_14
Rank: 1
等 级:新手上路
帖 子:196
专家分:0
注 册:2006-2-15
得分:0 
楼主的程序有好多地方 { 用的不对
this指的就是当前的object

2006-03-04 21:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-48304-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.257804 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved