tweencomponent.java.svn-base
来自「example2 众多JAVA实例源码...学习java基础的好帮手」· SVN-BASE 代码 · 共 84 行
SVN-BASE
84 行
package opusmicro.demos.animate2;
import javax.microedition.lcdui.Graphics;
public class TweenComponent implements Runnable{
private int width;
private int height;
private int x;
private int y;
public boolean isRunning = false;
TweenAnimateCanvas tac;
Thread thread;
int moveY = 1;
public TweenComponent(int x, int y, int width, int height,TweenAnimateCanvas tac) {
this.setX(x);
this.setY(y);
this.setWidth(width);
this.setHeight(height);
this.tac = tac;
thread = new Thread(this);
thread.start();
// new Thread(this).start();
}
public void paint(Graphics g, boolean isRunning){
this.isRunning = isRunning;
if(isRunning){
g.setColor(0xaab);
}else{
g.setColor(0xeeab);
}
g.fillRect(x, y, width, height);
}
void spash() throws InterruptedException {
tac.repaint();
y = y - 10;
Thread.sleep(100);
tac.repaint();
y = y + 20;
Thread.sleep(100);
tac.repaint();
y = y - 10;
}
public void run() {
while(isRunning){
try {
spash();
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?