求JAVA高手,奥特曼在哪里~哆啦A梦在哪里~葫芦娃在哪里~help~~~~

编写一个多线程程序,在应用程序窗口中显示一行从左到右移动的文字。

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JFrame;

public class TestThread extends JFrame implements Runnable {
int x=50,y=50;
public TestThread(){
setLocation(200, 200);
setSize(400,300);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

}
public static void main(String[] args) {
Thread t = new Thread(new TestThread());
t.start();
}

public void paint(Graphics g) {
super.paint(g);
g.drawString("小马哥来了",x,y);
}
public void run() {
while(true){
try {
Thread.sleep(1000);
x=x+5;//控制速度
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
repaint();
}

}

}
//你看看行吗呢不行告诉我
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-06-11
在心中
第2个回答  2011-06-11
在电视里