java进度条实例模板2014-10-20 16:49:02

( 1人已投票,[高质量] )
分享: ╬收藏
31.3K


java进度条实例模板:

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
     
     
     
public class GaugeUI extends Form implements CommandListener {
  private static final int MAX = 8;
  private static final int LEVELS = 8;
  int current = 0;
  Gauge gauge;
  Command stopCommand;
  boolean stop;
  boolean stopped;
     
  /** Creates a new instance of GaugeObserverUI */
  public GaugeUI() {
    super("");
    // 创建一个进度条
    gauge = new Gauge("", false, MAX, 0);
    stopCommand = new Command("停止", Command.STOP, 10);
    addCommand(stopCommand);
    append(gauge);
    setCommandListener(this);
     
  }
     
  // 初时化进度条
  public void init(String note, boolean stop) {
    gauge.setValue(0);
    setNote(note);
    setStop(stop);
    stopped = false;
  }
     
  // 进度条标题
  public void setNote(String note) {
    setTitle(note);
  }
     
  // 是否停止
  public boolean isStop() {
    return stop;
  }
     
  // 设置进度条停止
  public void setStop(boolean stop) {
    this.stop = stop;
  }
     
  // 是否已停止
  public boolean isStopped() {
    return stopped;
  }
     
  // 更新进度条
  public void updateGauge() {
    current = (current + 1) % LEVELS;
    gauge.setValue(current * MAX / LEVELS);
  }
     
  // 处理监听
  public void commandAction(Command c, Displayable d) {
    if (c == stopCommand) {
      stopped = true;
      stop();
    }
  }
     
  // 停止时事件处理
  public void stop() {
         
  }
}






头像

snowcoal
  • java
  • 进度条
  • 实例模板

收藏到我的私密空间

标题:java进度条实例模板

作者:柳岸花明

你暂未登录,请登录后才可收藏至您的私密空间 确认取消
雪炭网

键盘操作 更便捷 -雪炭网雪中送炭-乐趣无限