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

📄 gaugedisp.java

📁 在JBuilder上的Gauge的应用小例子。
💻 JAVA
字号:
package gaugedemo;

import javax.microedition.lcdui.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class GaugeDisp extends Form implements CommandListener,ItemStateListener,ItemCommandListener {
  Gauge g1,g2,g3,g4,g5,g6;
  Command showvalue;
  public GaugeDisp() {
    super("This is Gauge demo !");
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    // Set up this Displayable to listen to command events
    setCommandListener(this);
    // add the Exit command
    addCommand(new Command("Exit", Command.EXIT, 1));

    this.setItemStateListener(this);

    g1=new Gauge("interactive",true,6,1);
    g2=new Gauge("no_interactive",false,18,2);
    g3=new Gauge("non-interactive CONTINUOUS-IDLE",false,Gauge.INDEFINITE,Gauge.CONTINUOUS_IDLE);
    g4=new Gauge("non-interactive CONTINUOUS-RUNNING",false,Gauge.INDEFINITE,Gauge.CONTINUOUS_RUNNING);
    g5=new Gauge("non-interactive INCREMENTAL_IDLE",false,Gauge.INDEFINITE,Gauge.INCREMENTAL_IDLE);
    g6=new Gauge("non-interactive INCREMENTAL_UPDATING",false,Gauge.INDEFINITE,Gauge.INCREMENTAL_UPDATING);

    append(g1);
    append(g2);
    append(g3);
    append(g4);
    append(g5);
    append(g6);

    showvalue=new Command("show current value",Command.OK,1);
    g1.addCommand(showvalue);
    g1.setItemCommandListener(this);
  }

  public void commandAction(Command command, Displayable displayable) {
    /** @todo Add command handling code */
    if (command.getCommandType() == Command.EXIT) {
      // stop the MIDlet
      GaugeMIDlet.quitApp();
    }
  }
  public void commandAction(Command c,Item i){
    if(c==showvalue){
     System.out.println("When Enter command show value     "+g1.getValue());
     System.out.println("aaa"+g1.getMaxValue());
    }
  }
public void itemStateChanged(Item i){
  System.out.println("change"+g1.getValue());
}

}

⌨️ 快捷键说明

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