📄 timercanvas.txt
字号:
import java.util.Random;
import java.util.Timer;
import java.util.Vector;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
public class TimerCanvas extends Canvas{
Vector v;
Random r,gr,b;
public TimerCanvas(){
v=new Vector();
r=new Random();
gr=new Random();
b=new Random();
(new Timer()).schedule(new CreateBlock(this),3000,100);
}
public void addBlock(Block b){
v.addElement(b);
}
public void paint(Graphics g){
int red,green,blue;
red=Math.abs(r.nextInt())%255;
green=Math.abs(gr.nextInt())%150;
blue=Math.abs(b.nextInt())%200;
g.setColor(red,green,blue);
int i=v.size();
if(i-1>0)
{
Block b=(Block)v.elementAt(i-1);
g.fillRect(b.x,b.y,b.w,b.h);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -