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

📄 gaugemidlet.java

📁 j2me 手机编程实例
💻 JAVA
字号:
package com.j2medev.sample.chapter3;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class GaugeMidlet extends MIDlet implements Runnable,CommandListener {
    
    private Display display = null;
    private Gauge gauge = new Gauge("进度条", false, 99, 0);
    private Form form = new Form("UIDemo");
    private Command exitCommand = new Command("退出",Command.EXIT, 1);
    
    public void startApp() {
        if(display==null) {
            display = Display.getDisplay(this);
            form.append(gauge);
            form.addCommand(exitCommand);
            form.setCommandListener(this);
            display.setCurrent(form);
            //启动线程更新进度条
            new Thread(this).start();
        }
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
    
    public void run() {
        //当Gauge当前值小于最大值得时候,执行+1操作
        while(gauge.getValue()<gauge.getMaxValue()) {
            gauge.setValue(gauge.getValue()+1);
            try {
                Thread.sleep(100);
            } catch(InterruptedException ie) {}
        }
    }
    
    public void commandAction(Command cmd,Displayable displayable){
        if(cmd == exitCommand){
            destroyApp(false);
            notifyDestroyed();
        }
    }
    
}

⌨️ 快捷键说明

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