日期:2014-05-20 浏览次数:20897 次
/**
* @param path
* - the path used to create the buffered image.
* @return an BufferedImage object, or <code>null</code> if the given path
* is not valid or an error occurs during reading.
*/
private BufferedImage createImage(String path) {
URL imageURL = getClass().getResource(path);
if (imageURL != null) {
try {
return ImageIO.read(imageURL);
} catch (IOException e) {
System.err.println("an error occurs during reading.");
e.printStackTrace();
return null;
}
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}