gpt4 book ai didi

java - 无法在j2me应用程序中使用图像

转载 作者:行者123 更新时间:2023-11-30 04:58:44 25 4
gpt4 key购买 nike

我的应用程序中有一些图像:

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

最佳答案

red.png 图像放入 res 文件夹中,并在项目属性上添加 res 文件夹Libraries and Resources

关于java - 无法在j2me应用程序中使用图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7658140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com