资源描述:
《j2me手机游戏设计案例源代码-testform》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、*************TestFormimportjavax.microedition.lcdui.Command;importjavax.microedition.lcdui.Display;importjavax.microedition.lcdui.Form;importjavax.microedition.lcdui.Image;importjavax.microedition.lcdui.ImageItem;importjavax.microedition.lcdui.Item;importjavax.microedition.lcd
2、ui.ItemCommandListener;importjavax.microedition.lcdui.StringItem;importjavax.microedition.midlet.*;publicclassTestFormextendsMIDletimplementsItemCommandListener{privateDisplaydisplay;privateFormmainForm;privatefinalstaticCommandCMD_GO=newCommand("Go",Command.ITEM,1);privatefin
3、alstaticCommandCMD_PRESS=newCommand("Press",Command.ITEM,1);publicTestForm(){display=Display.getDisplay(this);mainForm=newForm("StringItemDemo");StringItemitem=newStringItem("ThisisaStringItemlabel:","ThisistheStringItemstext");item=newStringItem("label:","普通字符串");mainForm.app
4、end(item);item=newStringItem("Hyper-Link:","超链接字符串",Item.HYPERLINK);item.setDefaultCommand(CMD_GO);item.setItemCommandListener(this);mainForm.append(item);item=newStringItem("Button:","这是按钮",Item.BUTTON);item.setDefaultCommand(CMD_PRESS);item.setItemCommandListener(this);mainF
5、orm.append(item);Imageimg=null;try{img=Image.createImage("/Icon.png");}catch(Exceptione){}Formf=newForm("ImageItem测试");ImageItemii1=newImageItem("图片1",img,Item.LAYOUT_LEFT
6、Item.LAYOUT_NEWLINE_BEFORE,"图片1的替代文字",Item.BUTTON);f.append(ii1);ImageItemii2=newImageItem("图片2",img,Item
7、.LAYOUT_CENTER
8、Item.LAYOUT_NEWLINE_BEFORE,"图片2的替代文字",Item.BUTTON);f.append(ii2);ImageItemii3=newImageItem("图片3",img,Item.LAYOUT_RIGHT
9、Item.LAYOUT_NEWLINE_BEFORE,"图片3的替代文字",Item.HYPERLINK);f.append(ii3);display.setCurrent(f);}publicvoidstartApp(){}publicvoidpauseApp(){}publicvo
10、iddestroyApp(booleanunconditional){}publicvoidcommandAction(Commandarg0,Itemarg1){thrownewUnsupportedOperationException("Notsupportedyet.");}}