package javaGame;
import java.awt.*;
import java.applet.*;public class Ball extends Applet implements Runnable {
int x = 100;
int y = 20;
int r = 10;
public void init()
{
} public void start()
{
//定义一个新的线程
Thread th=new Thread(this);
th.start();
} public void stop() { } public void destroy() { } public void run () {
//
while(true)
{
//重画applet画面
repaint();
try
{
//暂停线程20毫秒
Thread.sleep(2);
}
catch(InterruptedException ex)
{
}
while(true)
{
//设置动画移动速度
y+=1;
}
}
} public void paint (Graphics g) {
//设置球的颜色
g.setColor(Color.blue);
//从x,y位置处画一个实心的圆
g.fillOval(x,y,2*r,2*r);
// g.drawString("xiaosheng",100,100);
} }
import java.awt.*;
import java.applet.*;public class Ball extends Applet implements Runnable {
int x = 100;
int y = 20;
int r = 10;
public void init()
{
} public void start()
{
//定义一个新的线程
Thread th=new Thread(this);
th.start();
} public void stop() { } public void destroy() { } public void run () {
//
while(true)
{
//重画applet画面
repaint();
try
{
//暂停线程20毫秒
Thread.sleep(2);
}
catch(InterruptedException ex)
{
}
while(true)
{
//设置动画移动速度
y+=1;
}
}
} public void paint (Graphics g) {
//设置球的颜色
g.setColor(Color.blue);
//从x,y位置处画一个实心的圆
g.fillOval(x,y,2*r,2*r);
// g.drawString("xiaosheng",100,100);
} }
解决方案 »
- 字符转十以内任意进制
- 一个简单的求总和运算
- [请教]那个给我讲解一下这个源代码的涵义
- 小弟的这个程序卡住了,关于jlist的使用...望高手指点,100分送上...
- jar双击没有反应?
- 一个动态数组的怪问题
- 开发jsp程序用什么环境比较好?那个配置方便一些?j2ee.1.4带了一个服务器,但不知道怎么配置,放在localhost:8080相应的目录里jsp也不能
- 如何在一个类文件中,显示另一个类文件中的记录集,(有分)
- 帮帮初学者!
- 谁看过Java网络编程,此书怎样?
- 哪位高手帮我看一下这个关于 java.lang.ArrayIndexOutOfBoundsException 的错误 弄了几天了 还没搞好!!
- 我写的扫雷, (新版),保正好,来的有分
各位高手这个程序错在哪?谢谢