又是Applet问题,郁闷(显示图片的)
下面得代码运行后提示又N多个异常,好像没有找到文件
//DisplayImage1.java
//author:YuYang
//This program is protected by copyright laws
//Display image
//<applet code="DisplayImage1.class" width="800" height="800">
//</applet>
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.applet.Applet;
public class DisplayImage1 extends Applet
{
public void paint(Graphics g)
{
try
{
URL pairURL=new URL("file:/D:/Photo/Products/17.jpg");
Image myImage=getImage(pairURL);
int w=myImage.getWidth(this);
int h=myImage.getHeight(this);
g.drawString("Width= "+w+" Height= "+h,10,10);
g.drawString("getFile= "+pairURL.getFile(),10,30);
g.drawImage(myImage,10,50,w,h,this);
}
catch(Exception e)
{
g.drawString("Image not found",30,30);
}
}
}