Java ImageIcon Load getImageIcon(URL url)

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

Description

get Image Icon

License

Apache License

Declaration

public static ImageIcon getImageIcon(URL url) 

Method Source Code

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

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

public class Main {
    public static ImageIcon getImageIcon(String fileName) {
        URL url = ClassLoader.getSystemResource(fileName);
        return getImageIcon(url);
    }//from  w  w w  . j av  a2  s .  c o  m

    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. getImageIcon(String path)
  2. getImageIcon(String path, String description)
  3. getImageIcon(String res)
  4. getImageIcon(String resource)
  5. getImageIcon(URL u, int w)
  6. getScaledInstance(Image img, int targetWidth, int targetHeight)
  7. loadImageIcon(byte bytes[], String descr)
  8. loadImageIcon(Class clas, String iconPath)
  9. loadImageIcon(String imageName)