j2ME中图片的加载路径问题,有完整的问题描述
classpath:E:\JBuilder2005\jdk1.4\lib\tools.jar;E:\JBuilder2005\jdk1.4\lib\dt.jar;.
工程路径:D:\javawork\j2me\SlideshowMidlet
图片存放位置:D:\javawork\j2me\SlideshowMidlet\
程序在JBuilder2005中编写,编译,运行
在运行的时候,抛出异常:Failed loading images!
源程序代码如下:(有二个类,运行类没有发上来)
import javax.microedition.lcdui.*;
import java.io.*;
public class SSCanvas extends Canvas {
private Display display;
private Image [] slides;
private String [] captions = { "A ", "B ", "C ", "D ", "E "};
private int curSlide = 0;
public SSCanvas(Display d){
super();
display = d;
//图片加载程序开始
try {
slides = new Image[5];
slides[0] = Image.createImage( "/A.gif ");
slides[1] = Image.createImage( "/B.gif ");
slides[2] = Image.createImage( "/C.gif ");
slides[3] = Image.createImage( "/D.gif ");
slides[4] = Image.createImage( "/E.gif ");
} catch (
IOException e) {
System.err.println( "Failed loading images! ");
}//图片加载结束
}
void start(){
display.setCurrent(this);
repaint();
}
public void keyPressed(int keyCode){
int action =getGameAction(keyCode);
switch(action){
case LEFT:
if(-- curSlide < 0 ){
curSlide = slides.length - 1;
}