Java Swing Icon loadIcon(String icon)

Here you can find the source of loadIcon(String icon)

Description

load Icon

License

Open Source License

Declaration

public static ImageIcon loadIcon(String icon) 

Method Source Code

//package com.java2s;
/**//ww w.j a v  a  2s.c  o m
 *
 * vsim
 *
 * This program is distributed under the terms of the GNU General Public License
 * The license is included in license.txt
 *
 * @author: Alejandro Vera
 *
 */

import javax.imageio.ImageIO;
import javax.swing.*;
import java.io.IOException;

public class Main {
    public static ImageIcon loadIcon(String icon) {
        if (icon == null) {
            return null;
        }
        try {
            return new ImageIcon(ImageIO.read(ClassLoader.getSystemResourceAsStream("icons/" + icon)));
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. grayIcon(Icon icon)
  2. iconFromStream(final InputStream in)
  3. item(String name, Icon icon)
  4. loadIcon(Class pRootClass, String strPath)
  5. loadIcon(ClassLoader classLoader, String path)
  6. loadIcon(String resourceName)
  7. loadIcons(String list, String path, Set ignore, ClassLoader loader)
  8. loadLoadingIcon()
  9. makeButtcon(Icon icon, Icon rollover, String tooltip, boolean is_toggle)