如何从小程序中的文件中绘制图像?
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
/*
<applet code = "DisplayImageExample" width = 500 height = 300>
<param name = "Image1" value = "one.jpg">
<param name = "Image2" value = "two.jpg">
</applet>
*/
public class NewApplet extends Applet
{
Image img1, img2;
public void init(){
img1 = getImage(getDocumentBase(), getParameter("aw.jpg"));
img2 = getImage(getDocumentBase(), getParameter("sd"));
}
public void paint(Graphics g){
//display an image using drwaImage method of Graphics class.
g.drawImage(img1, 1,5,this);
g.drawImage(img2, 100,100,this);
}
}
我是否正确设置了图像路径?