All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.techad.edc.popover.internal.swing.tools.ImageIconCreator Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package fr.techad.edc.popover.internal.swing.tools;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.net.URL;

/**
 * TECH ADVANTAGE
 * All right reserved
 * Created by cochon on 19/07/2017.
 */
public class ImageIconCreator {
    private static final Logger LOGGER = LoggerFactory.getLogger(ImageIconCreator.class);

    /**
     * Create an {@link ImageIcon}
     *
     * @param path the path of the icon
     * @return the ImageIcon
     */
    public static ImageIcon createImageIcon(String path) {
        URL imgURL = ClassLoader.getSystemClassLoader().getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            LOGGER.error("Couldn't find file: {}", path);
        }
        return new ImageIcon(path);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy