01: /**
02: * $RCSfile: XuiImagePanel.java,v $
03: * @creation 01/02/00
04: * @modification $Date: 2001/03/30 21:25:38 $
05: */package com.memoire.vainstall.xui;
06:
07: import java.awt.*;
08: import java.io.*;
09: import javax.swing.*;
10: import javax.swing.border.*;
11: import com.memoire.vainstall.VAGlobals;
12:
13: /**
14: * @version $Id: XuiImagePanel.java,v 1.1.1.1 2001/03/30 21:25:38 vonarnim Exp $
15: * @author Guillaume Desnoix
16: */
17:
18: public class XuiImagePanel extends XuiPanel {
19: public static final XuiImagePanel IMAGE_PANEL = new XuiImagePanel();
20:
21: public XuiImagePanel() {
22: super ();
23:
24: setBackground(Color.white);
25: setForeground(new Color(255, 224, 192));
26: // setBorder(new BevelBorder(BevelBorder.LOWERED));
27: // setBorder(new LineBorder(Color.black));
28:
29: InputStream imgStream = VAGlobals.BASE_CLASS
30: .getResourceAsStream("/" + VAGlobals.IMAGE);
31: if (imgStream == null) {
32: // setPreferredSize(new Dimension(200, 200));
33: } else {
34: ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
35: try {
36: byte[] buf = new byte[1024];
37: int read = imgStream.read(buf, 0, buf.length);
38: while (read > 0) {
39: dataStream.write(buf, 0, read);
40: read = imgStream.read(buf, 0, buf.length);
41: }
42: imgStream.close();
43: JLabel img = new JLabel(new ImageIcon(dataStream
44: .toByteArray()));
45: dataStream.close();
46: add(img);
47: } catch (IOException ex) {
48: // setPreferredSize(new Dimension(200, 200));
49: }
50: }
51: }
52: }
|