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.ImageIcon;

public class Main {
    /**
     * return image icon from resource location ( ie Classpath )
     * File could be placed in the classpath or in a jar file
     * @param aFilename file name of the image file
     * @param aRetriever object request for the image
     * @return image icon
     */
    public final static ImageIcon GetImageFromResource(String aFilename, Object aRetriever) {
        return GetImageFromResource(aFilename, aRetriever.getClass());
    }

    /**
     * return image icon from resource location ( ie Classpath )
     * File could be placed in the classpath or in a jar file
     * @param aFilename file name of the image file
     * @param aRetrieverClass class request for the image
     * @return image icon
     */
    public final static ImageIcon GetImageFromResource(String aFilename, Class aRetrieverClass) {
        URL url = null;
        url = aRetrieverClass.getResource(aFilename);
        if (url == null)
            return null;
        else
            return new ImageIcon(url);
    }
}