home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / WDESAMPL.BIN / ImageDisplayer.java,v < prev    next >
Text File  |  1997-06-18  |  1KB  |  78 lines

  1. head    1.2;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @# @;
  6.  
  7.  
  8. 1.2
  9. date    97.06.18.23.30.45;    author bucchere;    state Exp;
  10. branches;
  11. next    1.1;
  12.  
  13. 1.1
  14. date    97.06.18.23.30.20;    author bucchere;    state Exp;
  15. branches;
  16. next    ;
  17.  
  18.  
  19. desc
  20. @@
  21.  
  22.  
  23. 1.2
  24. log
  25. @Added package statement (used by switcher).
  26. @
  27. text
  28. @package alternative;
  29.  
  30. import java.awt.*;
  31. import java.applet.Applet;
  32.  
  33. public class ImageDisplayer extends Canvas {
  34.     Image image;
  35.     Dimension size;
  36.     int w, h;
  37.  
  38.     public ImageDisplayer(Image image, int width, int height) {
  39.     if (image == null) {
  40.         System.err.println("Canvas got invalid image object!");
  41.         return;
  42.     }
  43.  
  44.     this.image = image;
  45.  
  46.     w = width;
  47.     h = height;
  48.  
  49.     size = new Dimension(w,h);
  50.     }
  51.  
  52.     public Dimension preferredSize() {
  53.      return size;
  54.     }
  55.  
  56.     public synchronized Dimension minimumSize() {
  57.     return size;
  58.     }
  59.  
  60.     public void paint (Graphics g) {
  61.     if (image != null) {
  62.         g.drawImage(image, 0, 0, this);
  63.         g.drawRect(0, 0, w - 1, h - 1);
  64.     }
  65.     }
  66. }
  67.  
  68. @
  69.  
  70.  
  71. 1.1
  72. log
  73. @Initial revision
  74. @
  75. text
  76. @d1 2
  77. @
  78.