我正在尝试使用 LWUIT 创建初始屏幕。我想要一个表单加载和显示文本和图像 5 秒钟,然后继续下一个表单。我有一个代码,但无法显示图像。类和图像一起存储在同一个包中。相反,它会显示错误。
java.io.IOException
可能是什么问题?这是代码
package tungPackage;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.Label;
import javax.microedition.midlet.MIDlet;
public class photoMidlet extends MIDlet {
public void startApp() {
Display.init(this);
try {
Form splashscreen = new Form();
// Label splashText = new Label("Baldy");
Image image = Image.createImage("/splash.png");
Label pictureLabel = new Label(image);
splashscreen.addComponent(pictureLabel);
splashscreen.show();
} catch (Exception ex) {
Form x = new Form("ERROR");
String y = ex.toString();
Label g = new Label(y);
x.addComponent(g);
x.show();
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
使用 ZIP 实用程序(例如 7-zip)打开 JAR 文件并查看文件的根目录。如果飞溅.png不在罐子的根部,那就是你的问题!
放置飞溅.png使其位于罐子的根部。