KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > xui > XuiImagePanel


1 /**
2  * $RCSfile: XuiImagePanel.java,v $
3  * @creation 01/02/00
4  * @modification $Date: 2001/03/30 21:25:38 $
5  */

6
7 package com.memoire.vainstall.xui;
8
9 import java.awt.*;
10 import java.io.*;
11 import javax.swing.*;
12 import javax.swing.border.*;
13 import com.memoire.vainstall.VAGlobals;
14
15 /**
16  * @version $Id: XuiImagePanel.java,v 1.1.1.1 2001/03/30 21:25:38 vonarnim Exp $
17  * @author Guillaume Desnoix
18  */

19
20 public class XuiImagePanel
21        extends XuiPanel
22 {
23   public static final XuiImagePanel IMAGE_PANEL=new XuiImagePanel();
24
25   public XuiImagePanel()
26   {
27     super();
28     
29     setBackground(Color.white);
30     setForeground(new Color(255,224,192));
31     // setBorder(new BevelBorder(BevelBorder.LOWERED));
32
// setBorder(new LineBorder(Color.black));
33

34     InputStream imgStream=VAGlobals.BASE_CLASS.getResourceAsStream("/"+VAGlobals.IMAGE);
35     if( imgStream==null ) {
36       // setPreferredSize(new Dimension(200, 200));
37
} else {
38       ByteArrayOutputStream dataStream=new ByteArrayOutputStream();
39       try {
40         byte[] buf=new byte[1024];
41         int read=imgStream.read(buf, 0, buf.length);
42         while( read>0 ) {
43           dataStream.write(buf, 0, read);
44           read=imgStream.read(buf, 0, buf.length);
45         }
46         imgStream.close();
47         JLabel img=new JLabel(new ImageIcon(dataStream.toByteArray()));
48         dataStream.close();
49         add(img);
50       } catch( IOException ex ) {
51         // setPreferredSize(new Dimension(200, 200));
52
}
53     }
54   }
55 }
56
Popular Tags