org/homelinux/largo/utils/ImgComponent.java
author Markus Bröker <mbroeker@largo.homelinux.org>
Sat, 13 Dec 2008 13:41:26 +0100
changeset 1 930f3c241fa5
parent 0 e0dbaef72362
child 7 93fe1f21e0d8
permissions -rw-r--r--
URL moved to the git location

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 = null;

	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 ();
	}
}