org/homelinux/largo/utils/ImgComponent.java
author Markus Bröker <mbroeker@largo.homelinux.org>
Fri, 17 Dec 2010 22:33:17 +0100
changeset 14 f12f77aa13b2
parent 13 f83884cc7d2f
child 16 55b0d5006e7b
permissions -rw-r--r--
serialVersionUID starts with 1L...

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