import java.awt.*;
import java.applet.*;
import java.awt.geom.*;
import java.awt.font.*;
import java.awt.font.*;
import java.awt.image.*;
import java.net.*;
import java.net.URL;
public class GUIImage extends Applet{
public void paint(Graphics oldg)
{
Graphics2D g=(Graphics2D)oldg;
try
{
URL imgURL=new URL(getDocumentBase(),"Test.gif");
Image img=getImage(imgURL);
          int h=img.getHeight(this);
int w=img.getWidth(this);
BufferedImage buf=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
Graphics tmpG=buf.createGraphics();
tmpG.drawImage(img,10,10,this);
g.drawImage(buf,10,20,this);
}
catch(Exception e)
{
System.out.println("Error:"+e.getMessage());
}
}
}调试到int h=img.getHeight(this)时发现h=-1,而w正常。
这是为什么呢?