Here you can find the source of resizeImage(ImageIcon tmpIcon)
private static ImageIcon resizeImage(ImageIcon tmpIcon)
//package com.java2s; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class Main { public final static String jpeg = "jpeg"; public final static String jpg = "jpg"; public final static String gif = "gif"; public final static String png = "png"; private static ImageIcon resizeImage(ImageIcon tmpIcon) { if (tmpIcon != null) { if (tmpIcon.getIconWidth() > 90) { tmpIcon = new ImageIcon(tmpIcon.getImage().getScaledInstance(100, -1, Image.SCALE_DEFAULT)); }/* ww w . ja v a2 s . co m*/ } return tmpIcon; } public static BufferedImage getImage(String foldername, String filename) { BufferedImage image = null; String path = getImageLocation(foldername, filename); File file = getStoreFile(path); if (file != null) { System.out.println("File Path: " + file.getAbsolutePath()); try { image = ImageIO.read(file); } catch (IOException ioe) { System.err.println("Error reading image: " + ioe.getMessage()); } } return image; } public static String getImageLocation(String foldername, String filename) { //"./.images/logo/" return "./.images/" + foldername + "/" + filename; } public static File getStoreFile(String filename) { Path path = Paths.get(filename + "." + png); File file = path.toFile(); if (file.exists()) { return file; } path = Paths.get(filename + "." + jpeg); file = path.toFile(); if (file.exists()) { return file; } path = Paths.get(filename + "." + jpg); file = path.toFile(); if (file.exists()) { return file; } path = Paths.get(filename + "." + gif); file = path.toFile(); if (file.exists()) { return file; } return null; } }