Here you can find the source of getImage(Object obj, String filePath)
public static Image getImage(Object obj, String filePath)
//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; }//from ww w .j a v a2 s . c om 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); } }