1 package junit.awtui;
2
3 import java.awt.*;
4 import java.awt.image.*;
5 import java.net.URL;
6
7 import junit.runner.BaseTestRunner;
8
9 public class Logo extends Canvas {
10 private Image fImage;
11 private int fWidth;
12 private int fHeight;
13
14 public Logo() {
15 fImage= loadImage("logo.gif");
16 MediaTracker tracker= new MediaTracker(this);
17 tracker.addImage(fImage, 0);
18 try {
19 tracker.waitForAll();
20 } catch (Exception e) {
21 }
22
23 if (fImage != null) {
24 fWidth= fImage.getWidth(this);
25 fHeight= fImage.getHeight(this);
26 } else {
27 fWidth= 20;
28 fHeight= 20;
29 }
30 setSize(fWidth, fHeight);
31 }
32
33 public Image loadImage(String name) {
34 Toolkit toolkit= Toolkit.getDefaultToolkit();
35 try {
36 URL url= BaseTestRunner.class.getResource(name);
37 return toolkit.createImage((ImageProducer) url.getContent());
38 } catch (Exception ex) {
39 }
40 return null;
41 }
42
43 public void paint(Graphics g) {
44 paintBackground(g);
45 if (fImage != null)
46 g.drawImage(fImage, 0, 0, fWidth, fHeight, this);
47 }
48
49 public void paintBackground( java.awt.Graphics g) {
50 g.setColor(SystemColor.control);
51 g.fillRect(0, 0, getBounds().width, getBounds().height);
52 }
53 }