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