ImageItemAnimationRunnable.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- import javax.microedition.lcdui.*;
- public class ImageItemAnimationRunnable extends ImageItem implements Runnable {
- private boolean isRun = false;
- private Image[] images;
- private int NumofImage;
- private int index = 0;
- public ImageItemAnimationRunnable(String label, Image[] images, int layout, String altText,int NumofImage) {
- super(label, images[0], layout, altText);
- this.images = images;
- this.NumofImage = NumofImage;
- new Thread(this).start();
- }
- public void run() {
- while (!isRun) {
- this.setImage(images[index++]);
- if(index == NumofImage){
- index = 0;
- }
- try {
- Thread.currentThread().sleep(1000);
- } catch (InterruptedException err) {
- }
- }
- }
- void setDone() {
- isRun = true;
- }
- }