Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;

public class Main {
    /**
     * Gets an {@code Icon} given the url {@code resource}.
     * 
     * @param resource
     *            the url path to a valid icon
     * @return An {@code Icon}
     * @throws RuntimeException if the {@link ClassLoader} could not locate the resource.
     */
    @Deprecated
    public static Icon getIcon(String resource) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        URL url = cl.getResource(resource);
        if (null == url) {
            throw new RuntimeException("ClassLoader could not locate " + resource);
        }
        return new ImageIcon(url);
    }
}