Here you can find the source of createImageIcon(String path, int width, int height)
public static ImageIcon createImageIcon(String path, int width, int height)
//package com.java2s; //License from project: Creative Commons License import java.awt.Image; import java.net.URL; import javax.swing.ImageIcon; public class Main { public static ImageIcon createImageIcon(String path, int width, int height) { URL imgURL = ClassLoader.getSystemResource("img/" + path); return new ImageIcon(new ImageIcon(imgURL).getImage() .getScaledInstance(width, height, Image.SCALE_DEFAULT)); }// w w w. j av a 2 s . co m }