Java ImageIcon Load getImageIcon(String path)

Here you can find the source of getImageIcon(String path)

Description

getImageIcon.

License

Open Source License

Declaration

public static ImageIcon getImageIcon(String path) 

Method Source Code


//package com.java2s;

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

public class Main {
    /****************************************************************************
    * getImageIcon./*from   w  w  w . j  a v a 2s .  c  o m*/
    ****************************************************************************/
    public static ImageIcon getImageIcon(String path) {
        try {
            Object o = new Object();
            Class c = o.getClass();
            URL url = c.getResource("/" + path);
            return new ImageIcon(url);
        } catch (Exception e) {

        }
        try {
            return new ImageIcon(path);
        } catch (Exception e) {

        }
        return new ImageIcon();
    }
}

Related

  1. getImageIcon(Image imp, int width, int height)
  2. getImageIcon(String filename)
  3. getImageIcon(String filename, String description)
  4. getImageIcon(String name)
  5. getImageIcon(String name)
  6. getImageIcon(String path, String description)
  7. getImageIcon(String res)
  8. getImageIcon(String resource)
  9. getImageIcon(URL u, int w)