当前位置: 代码迷 >> J2ME >> J2ME学习札记_2
  详细解决方案

J2ME学习札记_2

热度:5658   发布时间:2013-02-25 21:31:56
J2ME学习笔记_2

?

每一个J2ME程序必须继承? javax.microedition.midlet.MIDlet;

?

J2ME程序生命周期是:

?

构造

运行

销毁

?

关于程序打包:右键-->J2ME-->create package 或者 create obfuscated pageage

?

?

Form类:

Command类:

package com.hoocy;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Form;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;public class MIDlet1 extends MIDlet {	/*BACK    CANCEL    EXIT  HELP  ITEM OK  SCREEN  STOP */	private Form form = new Form("我是FORM的标题");	private Command BACK = new Command("BACK", Command.BACK, 1);	private Command CANCEL = new Command("CANCEL", Command.CANCEL, 1);	private Command EXIT = new Command("EXIT", Command.EXIT, 1);	private Command HELP = new Command("HELP", Command.HELP, 1);	private Command ITEM = new Command("ITEM", Command.ITEM, 1);	private Command OK = new Command("OK", Command.OK, 1);	private Command SCREEN = new Command("SCREEN", Command.SCREEN, 1);	private Command STOP = new Command("STOP", Command.STOP, 1);	private Display display;	 	public MIDlet1() {		//获得一个display实例		display = Display.getDisplay(this);		display.setCurrent(form);		form.addCommand(BACK);		form.addCommand(CANCEL);		form.addCommand(EXIT);		form.addCommand(HELP);		form.addCommand(ITEM);		form.addCommand(OK);		form.addCommand(SCREEN);		form.addCommand(STOP);		System.out.println("构造函数");	}	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {		System.out.println("destroyApp");	}	protected void pauseApp() {		System.out.println("pauseApp");	}	protected void startApp() throws MIDletStateChangeException {		System.out.println("startApp");	}}
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!