import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class ShuangSeQiu2 extends MIDlet implements CommandListener {
private Display disp; // 引用MIDlet的Display 对象
private Form form;
private Command cmdOK;
private Command cmdExit;
private TextField textField;
private MyCalc myCalc;
public ShuangSeQiu2() {
super();
//---
disp = Display.getDisplay(this); // 获得当前MIDlet的Display对象,以便进行界面显示
//---
form = new Form("双色球机选程序");
//---
cmdOK = new Command("生成", Command.OK, 1);
cmdExit = new Command("退出", Command.EXIT, 1);
form.addCommand(cmdExit);
form.addCommand(cmdOK);
form.setCommandListener(this);
//---
textField = new TextField("","",4096,TextField.UNEDITABLE);
form.append(textField);
//---
myCalc = new MyCalc();
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
disp.setCurrent(form);
}
public void commandAction(Command arg0, Displayable arg1)
{
if (arg0 == cmdExit) { // 按下退出键时停止运行
try {
destroyApp(false);
} catch (MIDletStateChangeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.notifyDestroyed();
} else if (arg0 == cmdOK) { // 按下阅读键后阅读对应信息
textField.setString(myCalc.getSSQ());
}
}
}