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

📄 d0b60009ed9a001b1a36b107245978e8

📁 《J2ME实用教程》 源文件下载 本书没有仅仅局限于J2ME单机游戏的开发
💻
字号:
package com.chapter16.bankbillClent;

import javax.microedition.lcdui.*;



public class ProgressObserverUI extends Form implements ProgressObserver, 
        CommandListener {  
    private static final int GAUGE_MAX = 8;
    private static final int GAUGE_LEVELS = 4;
    int current = 0;
    Gauge gauge;
    Command stopCommand;
    boolean stoppable;
    boolean stopped;

    public ProgressObserverUI() {
        super("");
	//创建进度条
        gauge = new Gauge("", false, GAUGE_MAX, 0);
        stopCommand = new Command("停止", 
                                  Command.STOP, 10);
	//添加进度条
        append(gauge);
        setCommandListener(this);
    }
	//初始化屏幕
    public void init(String note, boolean stoppable) {
        gauge.setValue(0);
        setNote(note);
        setStoppable(stoppable);

        stopped = false;
    } 

    public void setNote(String note) {
        setTitle(note);
    } 
	//是否停止
    public boolean isStoppable() {
        return stoppable;
    } 
	//设置停止
    public void setStoppable(boolean stoppable) {
        this.stoppable = stoppable;

        if (stoppable) {
            addCommand(stopCommand);
        } else {
            removeCommand(stopCommand);
        } 
    } 

 
    public boolean isStopped() {
        return stopped;
    } 
	//进度条向前移动一级
    public void updateProgress() {
        current = (current + 1) % GAUGE_LEVELS;

        gauge.setValue(current * GAUGE_MAX / GAUGE_LEVELS);
    } 
	//处理命令
    public void commandAction(Command c, Displayable d) {
        if (c == stopCommand) {
            stopped = true;
        } 
    } 

}

⌨️ 快捷键说明

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