Java 如何将图像加载到小程序?

Java 如何将图像加载到小程序?,java,image,applet,Java,Image,Applet,我想将图像加载到小程序中,但每次运行程序时都会收到nullpointerexception。下面是我用来加载图像的代码。请帮忙 img = getImage(getDocumentBase(), getParameter("questionmark2.jpg")); g.drawImage(img, 100, 100, this); 您能为函数getImage添加代码吗getDocumentBase和getParameters?图像位于哪里?@CrApHeR,图像位于我的计算机上。尝试放置im

我想将图像加载到小程序中,但每次运行程序时都会收到nullpointerexception。下面是我用来加载图像的代码。请帮忙

img = getImage(getDocumentBase(), getParameter("questionmark2.jpg"));
g.drawImage(img, 100, 100, this);

您能为函数
getImage
添加代码吗
getDocumentBase
getParameters
?图像位于哪里?@CrApHeR,图像位于我的计算机上。尝试放置img=getImage(getDocumentBase(),“questionmark2.jpg”);