Here you can find the source of getImage(URL url)
public static Image getImage(URL url)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.awt.*; import javax.swing.*; import java.net.URL; public class Main { public static Image getImage(String fileName) { ImageIcon icon = getImageIcon(fileName); return (icon != null) ? icon.getImage() : null; }// w w w . j a va2s . co m public static Image getImage(URL url) { ImageIcon icon = getImageIcon(url); return (icon != null) ? icon.getImage() : null; } public static Image getImage(Object obj, String filePath) { URL url = obj.getClass().getResource(filePath); return getImage(url); } public static ImageIcon getImageIcon(String fileName) { URL url = ClassLoader.getSystemResource(fileName); return getImageIcon(url); } public static ImageIcon getImageIcon(URL url) { ImageIcon icon = (url == null) ? null : (new ImageIcon(url)); return icon; } public static ImageIcon getImageIcon(Object obj, String filePath) { URL url = obj.getClass().getResource(filePath); return getImageIcon(url); } }