求助Java基础问题
各位大哥,小弟新学Symbian上的Java编程,照着视频做的,源码如下。可以在屏幕上打出字"Thanks for your help.",但是无法画出图片ufo3.png。请问这是为何呢?
import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import javax.microedition.lcdui.*;public class midlet extends MIDlet { public midlet() {} protected void destroyApp(boolean arg0) throws MIDletStateChangeException {} protected void pauseApp() { } protected void startApp() throws MIDletStateChangeException { //把MyCanvas放到手机屏幕上。 Display.getDisplay(this).setCurrent(new MyCanvas()); }}class MyCanvas extends Canvas{ //Image background=null; //声明图像。此处有待解决问题,视频中background*null Image ufo=null; //Image airplane=null; MyCanvas() { try { //background=Image.createImage("/bomb.png"); //加载图像 ufo= Image.createImage("/ufo3.png"); } catch(Exception e) { e.printStackTrace(); } } protected void paint(Graphics graphic) { graphic.drawString("Thanks for your help..", 0, 0, 0); //graphic.drawImage(background, 20, 20, 0); //画图 graphic.drawImage(ufo, 0, 0, 0); } }