J2ME图片加载问题
我的程序加载图片时``运行就会一闪就没了``但是要是把加载图片那段代码去了```就能运行```请问是怎么回事啊!
我用的是JBULUDER2006```图片放在工程文件夹下的SRC文件夹下````
请高手帮忙看一下````````
package untitled2;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import
java.io.IOException;
import java.io.InputStream;
public class MainCanvas extends Canvas implements CommandListener{
private Display display;
private Image[] image1;
private String[] captions = { "img1 ", "img2 "};
private int curSlide = 0;
public MainCanvas(Display display) {
super();
try {
image1 = new Image[2];
image1[0] = Image.createImage( "/img1.png ");
image1[0] = Image.createImage( "/img2.png ");
this.display = display;
InputStream imageStream = getClass().getResourceAsStream( "/res/fly.png ");
System.out.println(null==imageStream);
//jbInit();
}
catch (
IOException e) {
System.err.print( "加载图片... ");
e.printStackTrace();
}
}
void start() {
display.setCurrent(this);
repaint();
}
private void jbInit() throws Exception {
// Set up this Displayable to listen to command events
setCommandListener(this);
// add the Exit command
addCommand(new Command( "退出 ", Command.EXIT, 1));
}
public void commandAction(Command command, Displayable displayable) {
/** @todo Add command handling code */
if (command.getCommandType() == Command.EXIT) {
// stop the MIDlet
MIDlet1.quitApp();
}
}
public void keyPressed(int keyCode) {
int action = getGameAction(keyCode);
switch (action) {
case LEFT:
if (--curSlide < 0) {