01: /**
02: * $RCSfile: VAImagePanel.java,v $
03: * @creation 01/02/00
04: * @modification $Date: 2001/03/30 21:25:38 $
05: */package com.memoire.vainstall.gui;
06:
07: import com.memoire.vainstall.VAGlobals;
08: import java.awt.*;
09: import java.io.*;
10: import javax.swing.*;
11: import javax.swing.border.*;
12:
13: /**
14: * @version $Id: VAImagePanel.java,v 1.1.1.1 2001/03/30 21:25:38 vonarnim Exp $
15: * @author Axel von Arnim
16: */
17:
18: public class VAImagePanel extends JLabel {
19: public static final VAImagePanel IMAGE_PANEL = new VAImagePanel();
20:
21: public VAImagePanel() {
22: super ();
23:
24: Dimension d = new Dimension(200, 400);
25: setBackground(Color.white);
26: setBorder(new BevelBorder(BevelBorder.LOWERED));
27: InputStream imgStream = VAGlobals.BASE_CLASS
28: .getResourceAsStream("/" + VAGlobals.IMAGE);
29: if (imgStream == null) {
30: setPreferredSize(d);
31: } else {
32: ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
33: try {
34: byte[] buf = new byte[1024];
35: int read = imgStream.read(buf, 0, buf.length);
36: while (read > 0) {
37: dataStream.write(buf, 0, read);
38: read = imgStream.read(buf, 0, buf.length);
39: }
40: imgStream.close();
41: ImageIcon image = new ImageIcon(dataStream
42: .toByteArray());
43: dataStream.close();
44: Insets i = getInsets();
45: image.setImage(image.getImage()
46: .getScaledInstance(d.width - i.left - i.right,
47: d.height - i.top - i.bottom,
48: Image.SCALE_SMOOTH));
49: setIcon(image);
50: setPreferredSize(d);
51: setMaximumSize(d);
52: } catch (IOException ex) {
53: setPreferredSize(d);
54: }
55: }
56: }
57: }
|