/** * Returns an <code>Image</code> object that can then be painted on * the screen. The <code>url</code> argument must specify an absolute * URL. The <code>name</code> argument is a specifier that is * relative to the <code>url</code> argument. * <p> * This method always returns immediately, whether or not the image * exists. When this applet attempts to draw the image on the screen, * the data will be loaded. The graphics primitives that draw the * image will incrementally paint on the screen. * * @param url an absolute URL giving the base location of the image. * @param name the location of the image, relative to the * <code>url</code> argument. * @return the image at the specified URL. * @see java.awt.Image */ public Image getImage(URL url, String name) { try { return getImage(new URL(url, name)); } catch (MalformedURLException e) { return null; } } 上面是J2SDK1.4.1说明文档中对getImage方法的说明,getImage方法位于java.applet包中
应该Toolkit.getDefaultToolkit().getImage(fd.getDirectory()+fd.getFile());
你的程序是从applet程序中copy的吧?
* Returns an <code>Image</code> object that can then be painted on
* the screen. The <code>url</code> argument must specify an absolute
* URL. The <code>name</code> argument is a specifier that is
* relative to the <code>url</code> argument.
* <p>
* This method always returns immediately, whether or not the image
* exists. When this applet attempts to draw the image on the screen,
* the data will be loaded. The graphics primitives that draw the
* image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image.
* @param name the location of the image, relative to the
* <code>url</code> argument.
* @return the image at the specified URL.
* @see java.awt.Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
上面是J2SDK1.4.1说明文档中对getImage方法的说明,getImage方法位于java.applet包中
Frame也没有getImage的方法呀。