⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noninteractivegaugerunnable.java

📁 J2ME手机游戏开发技术详解,适合初学者阅读使用
💻 JAVA
字号:
import javax.microedition.lcdui.*;public class NonInteractiveGaugeRunnable extends Gauge implements Runnable {    private int maxValue = 10;    private int delta = 1;    private boolean isRun = false;    private boolean isStop = false;    public NonInteractiveGaugeRunnable(String label, int maxValue,				       int initialValue) {        super(label, false, maxValue, initialValue);        this.maxValue = maxValue;        new Thread(this).start();    }    public void run() {        while (!isRun) {            // decide whether the gauge should start moving            // backwards or forwards.            if(!isStop){            int newValue = getValue() + delta;            if (newValue == maxValue) {                delta = -1;            } else if (newValue == 0) {                delta = 1;            }            setValue(newValue);            }            try {                Thread.currentThread().sleep(1000);            } catch (InterruptedException err) {            }        }    }    void setDone() {        isRun = true;    }    void reStart(){    	isStop = false;    }    void stop(){        isStop = true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -