SimpleBeanInfo.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:openjdk-jdk10 作者:
/**
 * This is a utility method to help in loading icon images. It takes the
 * name of a resource file associated with the current object's class file
 * and loads an image object from that file. Typically images will be GIFs.
 *
 * @param  resourceName A pathname relative to the directory holding the
 *         class file of the current class. For example, "wombat.gif".
 * @return an image object or null if the resource is not found or the
 *         resource could not be loaded as an Image
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号