Here you can find the source of getScaledImage(ImageIcon icon, int w, int h)
public static Image getScaledImage(ImageIcon icon, int w, int h)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics2D; import java.awt.Image; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; public class Main { public static Image getScaledImage(ImageIcon icon, int w, int h) { BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(icon.getImage(), 0, 0, w, h, null); g2.dispose();/*from w w w . ja va 2 s .c o m*/ return resizedImg; } }