public static BufferedImage getScaledInstance(ImageIcon image,
			int targetWidth,
			int targetHeight)
	{
		if(imageCache.containsKey(image.toString()+'|'+targetWidth+'|'+targetHeight))
			return imageCache.get(image.toString()+'|'+targetWidth+'|'+targetHeight);
		
		BufferedImage img = new BufferedImage(
				image.getIconWidth(),
				image.getIconHeight(),
				BufferedImage.TYPE_INT_RGB);
		Graphics g1 = img.createGraphics();
		image.paintIcon(null, g1, 0,0);
		g1.dispose();
		
		BufferedImage ret = img;
		int w = img.getWidth(), h = img.getHeight();
		
		do
		{
			if(w != targetWidth)
			{
				w /= 2;
				if (w < targetWidth)
				{
					w = targetWidth;
				}
			}
			
			if(h != targetHeight)
			{
				h /= 2;
				if (h < targetHeight)
				{
					h = targetHeight;
				}
			}
			
			BufferedImage tmp = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
			Graphics2D g2 = tmp.createGraphics();
			g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
			g2.drawImage(ret, 0, 0, w, h, null);
			g2.dispose();
			
			ret = tmp;
		} while(w != targetWidth || h != targetHeight);
		
		imageCache.put(image.toString()+'|'+targetWidth+'|'+targetHeight, ret);
		
		return ret;
	}