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

org.meteoinfo.image.svg.SVGUtil Maven / Gradle / Ivy

There is a newer version: 3.8
Show newest version
package org.meteoinfo.image.svg;

import com.formdev.flatlaf.extras.FlatSVGIcon;

import javax.swing.*;

public class SVGUtil {

    /**
     * Set SVG icon
     * @param button The button
     * @param iconPath SVG icon path
     */
    public static void setSVGIcon(AbstractButton button, String iconPath) {
        try {
            FlatSVGIcon icon = new FlatSVGIcon(iconPath);
            if (icon.hasFound()) {
                button.setIcon(icon);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Set SVG icon
     * @param button The button
     * @param iconPath SVG icon path
     * @param classLoader ClassLoader
     */
    public static void setSVGIcon(AbstractButton button, String iconPath, ClassLoader classLoader) {
        try {
            FlatSVGIcon icon = new FlatSVGIcon(iconPath, classLoader);
            if (icon.hasFound()) {
                button.setIcon(icon);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy