13,100
社区成员
发帖
与我相关
我的任务
分享
public class Convert extends MIDlet implements CommandListener {
public final String SoftName = "转换";
private Units unit = null;
private Display display;
protected List unitList;
public Command exitBtn, backIndexBtn, countBtn;
protected Alert welcomeAlert, infoAlert;
public TextField valueField;
public StringItem resultStringItem;
public Convert() {
display = Display.getDisplay(this);
// Welcome Page
welcomeAlert = new Alert("", SoftName + " \n Version 1.0", null, AlertType.INFO);
welcomeAlert.setTimeout(2000);
// Init Commands
Init.initCommand(this);
// Init Item
valueField = new TextField("", "", 100, TextField.NUMERIC);
resultStringItem = new StringItem("结果:", null);
// Init List or Form
Init.initUnitList(this);
}
protected void destroyApp(boolean arg0) {}
protected void pauseApp() {}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(unitList);
display.setCurrent(welcomeAlert);
}
public void commandAction(Command cmd0, Displayable arg1) {
if (cmd0 == exitBtn) {
destroyApp(true);
notifyDestroyed();
} else if (cmd0 == backIndexBtn) {
display.setCurrent(unitList);
valueField.setString("");
resultStringItem.setText("");
if (unit != null) {
unit.destroyForm();
}
} else if (cmd0 == countBtn) {
unit.count(this);
} else if (cmd0 == List.SELECT_COMMAND) {
if (unitList.isShown()) {
int curUnitType = unitList.getSelectedIndex();
switch(curUnitType) {
case 0:
unit = new AccelerationAngular(this);
break;
case 1:
unit = new AccelerationLinear(this);
break;
case 2:
unit = new Angle(this);
break;
}
}
}
}
public Display getDisplay() {
return this.display;
}