noninteractivegaugerunnable.java

来自「J2ME程序实现开机自启动的简单例子源码。」· Java 代码 · 共 75 行

JAVA
75
字号
/* * %W% %E% * * Copyright (c) 2000-2004 Sun Microsystems, Inc. All rights reserved.  * PROPRIETARY/CONFIDENTIAL * Use is subject to license terms */package com.ultrapower.model;import javax.microedition.lcdui.*;/** * This class implements a non-interactive gague control * that moves automatically, between the min and max values. * * @version 2.0 */public class NonInteractiveGaugeRunnable extends Gauge implements Runnable {    private int maxValue = 10;    /**     * This member indicates the number of units to move per     * iteration. It is set to -1 when we reach a 100 and 1     * when we reach 0.     */    private int delta = 1;    private boolean done = false;        /**     * The constructor initializes the gauge.     */    public NonInteractiveGaugeRunnable(String label, int maxValue,				       int initialValue) {        super(label, false, maxValue, initialValue);        this.maxValue = maxValue;        new Thread(this).start();    }    /**     * This method moves the gauge left and right.     */    public void run() {        while (!done) {            // decide whether the gauge should start moving            // backwards or forwards.            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) {            }        }    }        public void setDone() {        done = true;    }		public void setStart() {        done = false;    }}

⌨️ 快捷键说明

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