Here you can find the source of scaleIcon(int width, int height, ImageIcon img)
Parameter | Description |
---|---|
width | new width |
height | new height |
img | image icon to resize |
public static ImageIcon scaleIcon(int width, int height, ImageIcon img)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; public class Main { /**//from www. j a v a2 s. com * Scales the given image icon to the input width/height * * @param width new width * @param height new height * @param img image icon to resize * @return scaled image icon */ public static ImageIcon scaleIcon(int width, int height, ImageIcon img) { return new ImageIcon(scaleImage(width, height, img.getImage())); } /** * Scales the given image to the input width/height * * @param width new width * @param height new height * @param img img to resize * @return scaled image */ public static Image scaleImage(int width, int height, Image img) { return img.getScaledInstance(width, height, Image.SCALE_SMOOTH); } }