Java Image Load getImage(URL url)

Here you can find the source of getImage(URL url)

Description

get Image

License

Apache License

Declaration

public static Image getImage(URL url) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.awt.*;

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

public class Main {
    public static Image getImage(String fileName) {
        ImageIcon icon = getImageIcon(fileName);
        return (icon != null) ? icon.getImage() : null;
    }//  w w  w  . j a  va2s  . co  m

    public static Image getImage(URL url) {
        ImageIcon icon = getImageIcon(url);
        return (icon != null) ? icon.getImage() : null;
    }

    public static Image getImage(Object obj, String filePath) {
        URL url = obj.getClass().getResource(filePath);
        return getImage(url);
    }

    public static ImageIcon getImageIcon(String fileName) {
        URL url = ClassLoader.getSystemResource(fileName);
        return getImageIcon(url);
    }

    public static ImageIcon getImageIcon(URL url) {
        ImageIcon icon = (url == null) ? null : (new ImageIcon(url));
        return icon;
    }

    public static ImageIcon getImageIcon(Object obj, String filePath) {
        URL url = obj.getClass().getResource(filePath);
        return getImageIcon(url);
    }
}

Related

  1. getImage(String imageName, String path)
  2. getImage(String path)
  3. getImage(String path)
  4. getImage(String text, boolean clockwise)
  5. getImage(String url)
  6. getImageFromClassResource(Class cls, String resource)
  7. getImageFromFile(String fileName)
  8. getImageFromSource(JPanel source, Dimension dim)
  9. getLocal(String imagePath)