求交互性Gauge例子程序,该如何处理

www.MyException.Cn  网友分享于：2013-03-04  浏览：5次

------解决方案--------------------

Java code
```

/*
* GaugeTestMidlet.java
*
* Created on 2006年2月23日, 下午3:30
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
*
* @author Allan
* @version
*/
public class GaugeMidlet extends MIDlet implements CommandListener {
private Display display;

private Gauge g1;

private Command c1;

private Command c2;

private Command c3;

private Command c4;

public GaugeMidlet() {
display = Display.getDisplay(this);
c1 = new Command("CONTINUOUS_IDLE", Command.SCREEN, 1);
c2 = new Command("CONTINUOUS_RUNNING", Command.SCREEN, 1);
c3 = new Command("INCREMENTAL_IDLE", Command.SCREEN, 1);
c4 = new Command("INCREMENTAL_UPDATING", Command.SCREEN, 1);
}

public void startApp() {
Form f = new Form("Gauge test");
g1 = new Gauge("进度条一", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_IDLE);
// g1 = new Gauge("进度条一", false, Gauge.INDEFINITE,
// Gauge.CONTINUOUS_RUNNING);
// g1 = new Gauge("进度条一", false, Gauge.INDEFINITE,
// Gauge.INCREMENTAL_IDLE);
// g1 = new Gauge("进度条一", false, Gauge.INDEFINITE,
// Gauge.INCREMENTAL_UPDATING);
f.setCommandListener(this);
f.append(g1);
display.setCurrent(f);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable s) {
// g1.setMaxValue(2);

if (c == c1) {
g1.setValue(Gauge.CONTINUOUS_IDLE);
} else if (c == c2) {
g1.setValue(Gauge.CONTINUOUS_RUNNING);
} else if (c == c3) {
g1.setValue(Gauge.INCREMENTAL_IDLE);
} else if (c == c4) {
g1.setValue(Gauge.INCREMENTAL_UPDATING);
}
System.out.println(g1.getValue());
System.out.println(g1.getMaxValue());
}
}```