Java Image Load getImage(String path)

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

Description

get Image

License

Creative Commons License

Declaration

public static Image getImage(String path) 

Method Source Code

//package com.java2s;
/**// w  w w  .j a  va2 s  .c o  m
 * Copyright 2013 by PanicLauncher and Contributors
 *
 * This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/.
 */

import java.awt.Image;

import java.net.URL;

import javax.swing.ImageIcon;

public class Main {
    public static Image getImage(String path) {
        URL url = System.class.getResource(path);

        if (url == null) {
            System.err.println("Unable to load image: " + path);
        }

        ImageIcon icon = new ImageIcon(url);

        return icon.getImage();
    }
}

Related

  1. getImage(String imageName, String path)
  2. getImage(String path)
  3. getImage(String text, boolean clockwise)
  4. getImage(String url)
  5. getImage(URL url)