无法在j2me应用程序中使用图像
我的应用程序中有一些图像:
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageCreateImage extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem(null, red, ImageItem.LAYOUT_DEFAULT, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
但 NetBeans 给出错误:
[WARN] [rms ] javacall_file_open: _wopen failed for: C:\Users\Win7\javame-sdk\3.0\work\0\appdb\_delete_notify.dat
[WARN] [rms ] javacall_file_open: _wopen failed for: C:\Users\Win7\javame-sdk\3.0\work\0\appdb\00000002red-6png.tmp
javacall_lifecycle_state_changed() lifecycle: event is JAVACALL_LIFECYCLE_MIDLET_SHUTDOWNstatus is JAVACALL_OK
I have some images in my application:
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageCreateImage extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem(null, red, ImageItem.LAYOUT_DEFAULT, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
but NetBeans gives an error:
[WARN] [rms ] javacall_file_open: _wopen failed for: C:\Users\Win7\javame-sdk\3.0\work\0\appdb\_delete_notify.dat
[WARN] [rms ] javacall_file_open: _wopen failed for: C:\Users\Win7\javame-sdk\3.0\work\0\appdb\00000002red-6png.tmp
javacall_lifecycle_state_changed() lifecycle: event is JAVACALL_LIFECYCLE_MIDLET_SHUTDOWNstatus is JAVACALL_OK
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
red.png
图像放入 res 文件夹中,并在项目属性上添加 res 文件夹Libraries and Resources。Place the
red.png
image inside of res folder and add the res folder Libraries and Resources on project properties.