|
发表于 2011-11-4 10:34:42
|
显示全部楼层
Re:请高手帮
主程序:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class gaugeDemo_2
extends MIDlet
implements CommandListener {
private Command exitCommand, alertCommand;
private TextBox tb;
private GaugeThread gthread;
public gaugeDemo_2() {
exitCommand = new Command("exit", Command.EXIT, 1);
alertCommand = new Command("Alert MIDlet", Command.SCREEN, 1);
tb = new TextBox("Alert MIDlet", "Alert Example!", 15, 0);
tb.addCommand(exitCommand);
tb.addCommand(alertCommand);
tb.setCommandListener(this);
gthread = new GaugeThread("thread", 40, 0);
new Thread(gthread).start();
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(tb);
}
protected void pauseApp() {
}
protected void destroyApp(boolean boolean0) {
gthread.setDone();
}
public void commandAction(Command c, Displayable displayable) {
if (c == alertCommand) {
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
}
Alert info = new Alert("Alert", "This is a Alert Example", null,
AlertType.INFO); //提示給用户菲威胁性信息
info.setTimeout(10000);
Gauge indicator = new Gauge(null, false, 10, 0);
info.setIndicator(indicator);
// info.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(info);
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
} |
|