Java ImageIcon Create createImageIcon(String path, String description)

Here you can find the source of createImageIcon(String path, String description)

Description

Returns an ImageIcon, or null if the path was invalid.

License

Open Source License

Declaration

public static ImageIcon createImageIcon(String path, String description) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.ImageIcon;

public class Main {
    /** Returns an ImageIcon, or null if the path was invalid. */
    public static ImageIcon createImageIcon(String path, String description) {
        return new ImageIcon(path, description);
        /*//from   w  w  w  . j a  va2 s . co  m
        java.net.URL imgURL = getClass().getResource(path);
        if (imgURL != null) {
        return new ImageIcon(imgURL, description);
        } else {
        System.err.println("Couldn't find file: " + path);
        return null;
        }
        */
    }
}

Related

  1. createImageIcon(String path)
  2. createImageIcon(String path)
  3. createImageIcon(String path, Class resourceClass)
  4. createImageIcon(String path, Class c)
  5. createImageIcon(String path, int width, int height)
  6. createImageIcon(String path, String description)
  7. createImageIcon(String resourcePath)
  8. createImageIcon(URL url)
  9. createImageIcon(URL url, String description, Integer w, Integer h)