, 0, this); } catch (RecordStoreException e) { this.showAlertError(e.getMessage()); } Form mainForm = new Form("RMS测试器"); Image mainImage = getMainImage("java.png"); if (mainImage != null) { mainForm.append(mainImage); } else { mainForm.append("欢迎使用自由软件"); } mainForm.addCommand(startCommand); mainForm.addCommand(exitCommand); mainForm.setCommandListener(this); display.setCurrent(mainForm);
}
public Image getMainImage(String name) { Image image = null; try { image = Image.createImage("/" + name); } catch (IOException e) { return null; } return image; }
public Display getDisplay() { return display; }
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
public void commandAction(Command cmd, Displayable disp) { if (cmd == startCommand) { display.setCurrent(counterCanvas); counterCanvas.start(); } else if (cmd == exitCommand) { exitMIDlet(); } }
public void exitMIDlet() { try { destroyApp(false); notifyDestroyed(); } catch (MIDletStateChangeException e) { showAlertError(e.getMessage()); } }
public void showAlertError(String message) { alert.setString(message); alert.setType(AlertType.ERROR); alert.setTimeout(2500); display.setCurrent(alert);
}
}
import java.util.Timer; import java.util.TimerTask;
import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Graphics; import javax.microedition.rms.*;
public class CounterCanvas extends Canvas implements CommandListener {
private RMSModel model; private RMSAnalyzer RMSanalyzer; private int interTime; private int counter; private boolean go = true; public static Command exitCommand 上一页 [1] [2] [3] [4] 下一页 |