日期:2014-05-20 浏览次数:20638 次
/** * prj5_1.java * 使用ChoiceGroup * @ author * @ version 1.0 * create on 2008-10-27 */ package src; import javax.microedition.lcdui.*; import javax.microedition.lcdui.Display; //import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; //import javax.microedition.lcdui.Item; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; public class prj5_2 extends MIDlet { private Form mainForm=new Form("这是一个含有ImageItem的Form"); private Display dis; private ImageItem imageItem; public prj5_2() { // TODO Image img=null; try{ img=Image.createImage("/pics/img.png"); //在这里,如果这张图片和JAVA源文件在同一文件夹,如何处理? }catch(Exception ex){ ex.printStackTrace(); } imageItem= new ImageItem("Picture",img,ImageItem.LAYOUT_CENTER|Item.LAYOUT_EXPAND,"该图像无法装载"); } protected void startApp() throws MIDletStateChangeException { dis=Display.getDisplay(this); dis.setCurrent(mainForm); mainForm.append(imageItem); // TODO } protected void destroyApp(boolean arg0) throws MIDletStateChangeException { // TODO } protected void pauseApp() { // TODO } }