org/homelinux/largo/utils/ImgComponent.java
author Markus Bröker <mbroeker@largo.homelinux.org>
Wed, 13 May 2009 14:08:44 +0200
changeset 9 506c7ab82d39
parent 7 93fe1f21e0d8
child 13 f83884cc7d2f
permissions -rw-r--r--
ant build file improved this will be the default build file for all my java projects

package org.homelinux.largo.utils;

import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon;

public class ImgComponent extends Canvas {
	static final long serialVersionUID = 140208;
	private Image img;

	public ImgComponent (String sFile) {
		ClassLoader cl = getClass ().getClassLoader ();
		URL url = cl.getResource (sFile);
		img = new ImageIcon (url).getImage ();
	}

	public Image getImage () {
		return img;
	}

	public Dimension getPreferredSize () {
		return new Dimension (img.getWidth (this), img.getHeight (this));
	}

	public Dimension getMinimumSize () {
		return getPreferredSize ();
	}
}