Here you can find the source of CreateSizedImageIconScaledSmooth(URL filePath, int width, int height)
Parameter | Description |
---|---|
filePath | - The image to resize |
width | - The new width to scale to |
height | - The new height to scale to |
public static ImageIcon CreateSizedImageIconScaledSmooth(URL filePath, int width, int height)
//package com.java2s; //License from project: Apache License import java.awt.Image; import java.net.URL; import javax.swing.ImageIcon; public class Main { /**//from w ww . ja va 2 s.c o m * Scales the provided image to the new height/width * @param filePath - The image to resize * @param width - The new width to scale to * @param height - The new height to scale to * @return ImageIcon - the newly resized image */ public static ImageIcon CreateSizedImageIconScaledSmooth(URL filePath, int width, int height) { ImageIcon newImageIcon = new ImageIcon(filePath); Image image = newImageIcon.getImage(); image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); newImageIcon = new ImageIcon(image); return newImageIcon; } }