J2ME版本的HelloWord (MIDP2.0)

来源:互联网 发布:淘宝达人是什么意思 编辑:程序博客网 时间:2024/05/20 08:23
献上J2me最简单的Hello一个,小弟也在加深学习中,但是由于工作和学业,俺的学习进度较慢。
import javax.microedition.midlet.MIDlet;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Displayable;public class TestMidlet extends MIDlet implements CommandListener {private Form screenForm;private Command exit;public TestMidlet() {screenForm = new Form("Heipark");exit = new Command("Quit", Command.EXIT, 1);screenForm.append("Hello,Buddy");screenForm.addCommand(exit);screenForm.setCommandListener(this);}public void startApp(){Display.getDisplay(this).setCurrent(screenForm);}// 处理键盘事件,该方法是实现的接口方法public void commandAction(Command cmd, Displayable displayable) {if(cmd.getCommandType() == Command.EXIT){destroyApp(true);notifyDestroyed();}}public void destroyApp(boolean unconditional){}public void pauseApp() {}}
原创粉丝点击