📄 bball.java
字号:
import java.applet.*;
import java.awt.*;
class Redball extends Thread{
Graphics red; int t=0;
public Redball(Applet s){
red=s.getGraphics();
red.setColor(Color.red);
}
public void run(){
while(true)
{t++;
if(t>100)t=0;
red.clearRect(0,0,110,600);
red.fillOval(50,(int)(1.0/2*t*9.8),5,5);
try{sleep(40);}catch(InterruptedException e){}
}
}}
class Blueball extends Thread{
Graphics blue; int t=0;
public Blueball(Applet s){
blue=s.getGraphics();
blue.setColor(Color.blue);
}
public void run(){
while(true)
{t++;
if(t>100)t=0;
blue.clearRect(120,0,900,500);
blue.fillOval(120+7*t,(int)(1.0/2*t*9.8),5,5);
try{sleep(40);}catch(InterruptedException e){}
}
}}
public class Bball extends Applet
{public void init(){
Redball redball=new Redball(this);
Blueball blueball=new Blueball(this);
redball.start();
blueball.start();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -