org/homelinux/largo/utils/ImgComponent.java
changeset 13 f83884cc7d2f
parent 7 93fe1f21e0d8
child 14 f12f77aa13b2
equal deleted inserted replaced
12:d28c1e402d82 13:f83884cc7d2f
     6 import java.net.URL;
     6 import java.net.URL;
     7 
     7 
     8 import javax.swing.ImageIcon;
     8 import javax.swing.ImageIcon;
     9 
     9 
    10 public class ImgComponent extends Canvas {
    10 public class ImgComponent extends Canvas {
    11 	static final long serialVersionUID = 140208;
    11     static final long serialVersionUID = 140208;
    12 	private Image img;
    12     private Image img;
    13 
    13 
    14 	public ImgComponent (String sFile) {
    14     public ImgComponent(String sFile) {
    15 		ClassLoader cl = getClass ().getClassLoader ();
    15         ClassLoader cl = getClass().getClassLoader();
    16 		URL url = cl.getResource (sFile);
    16         URL url = cl.getResource(sFile);
    17 		img = new ImageIcon (url).getImage ();
    17         img = new ImageIcon(url).getImage();
    18 	}
    18     }
    19 
    19 
    20 	public Image getImage () {
    20     public Image getImage() {
    21 		return img;
    21         return img;
    22 	}
    22     }
    23 
    23 
    24 	public Dimension getPreferredSize () {
    24     public Dimension getPreferredSize() {
    25 		return new Dimension (img.getWidth (this), img.getHeight (this));
    25         return new Dimension(img.getWidth(this), img.getHeight(this));
    26 	}
    26     }
    27 
    27 
    28 	public Dimension getMinimumSize () {
    28     public Dimension getMinimumSize() {
    29 		return getPreferredSize ();
    29         return getPreferredSize();
    30 	}
    30     }
    31 }
    31 }