首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2ME开发 >

J2ME学习札记_2

2012-09-19 
J2ME学习笔记_2?每一个J2ME程序必须继承? javax.microedition.midlet.MIDlet?J2ME程序生命周期是:?构造运

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");}}

热点排行