j2me NullPointerException将图像添加到矢量

时间:2010-01-27 15:23:01

标签: image java-me vector nullpointerexception

private Vector menuOptions;

void addOption(String imagefilename) {
    try {
        Image i = Image.createImage(imagefilename);
        menuOptions.addElement((Object)i);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

我得到了: 显示java.lang.NullPointerException     在GraphicMenu.addOption(GraphicMenu.java:31)// addElement line

我可以将Inmutable图像添加到Vector对象吗?

1 个答案:

答案 0 :(得分:0)

您是否初始化了载体?

Vector menuOptions = new Vector();