home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 July & August / Pcwk78a98.iso / Internet / Javadraw / DATA.Z / Compatibility.java,v < prev    next >
Text File  |  1997-06-20  |  3KB  |  139 lines

  1. head    1.3;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @# @;
  6.  
  7.  
  8. 1.3
  9. date    97.06.20.15.51.57;    author bucchere;    state Exp;
  10. branches;
  11. next    1.2;
  12.  
  13. 1.2
  14. date    97.06.18.23.25.11;    author bucchere;    state Exp;
  15. branches;
  16. next    1.1;
  17.  
  18. 1.1
  19. date    97.06.18.23.24.45;    author bucchere;    state Exp;
  20. branches;
  21. next    ;
  22.  
  23.  
  24. desc
  25. @@
  26.  
  27.  
  28. 1.3
  29. log
  30. @Changed "What am I missing?" to "Click here to see what you're missing!" on
  31. Doug's suggestion -- he thought it was hard to tell that the gray screen is
  32. actually a button.
  33. @
  34. text
  35. @package alternative;
  36.  
  37. import java.applet.*;
  38. import java.awt.*;
  39.  
  40. public class Compatibility extends Applet {
  41.     /* Should localize the following. */
  42.     protected String labelText = "Your browser can't run 1.1 applets.";
  43.     protected String filename;   // value to be provided by a subclass
  44.     PictureFrame frame;
  45.  
  46.     public void init() {
  47.     setLayout(new BorderLayout());
  48.  
  49.     Button button = new Button("Click here to see what you're missing!");
  50.     add("Center", button);
  51.  
  52.     Label label = new Label(labelText);
  53.     label.setForeground(Color.red);
  54.     add("North", label);
  55.  
  56.     System.out.println("Image filename is " + filename);
  57.  
  58.     if (filename == null) {
  59.         label.disable();
  60.         button.disable();
  61.         return;
  62.     } 
  63.     //needed because this is running under Switcher
  64.     Applet parentApplet;
  65.     
  66.     /* Get the parent Applet object. */
  67.     try {
  68.       parentApplet = (Applet)getParent();
  69.     } catch (ClassCastException e) {
  70.       System.err.println("Parent isn't an Applet!");
  71.       throw(e);
  72.     }
  73.         
  74.     Image image = parentApplet.getImage(parentApplet.getCodeBase(), filename);
  75.     String gifWidth = parentApplet.getParameter("GIFWIDTH");
  76.     String gifHeight = parentApplet.getParameter("GIFHEIGHT");
  77.     int w = 200;
  78.     int h = 200;
  79.  
  80.     if (gifWidth != null) {
  81.         try {
  82.         w = Integer.parseInt(gifWidth);
  83.         } catch (NumberFormatException e) {
  84.         //Use default width.
  85.         }
  86.     }
  87.  
  88.     if (gifHeight != null) {
  89.         try {
  90.         h = Integer.parseInt(gifHeight);
  91.         } catch (NumberFormatException e) {
  92.         //Use default height.
  93.         }
  94.     }
  95.  
  96.     frame = new PictureFrame(image, w, h);
  97.     }
  98.  
  99.     public void stop() {
  100.     frame.hide();
  101.     }
  102.  
  103.     public boolean action(Event e, Object arg) {
  104.     if (frame != null) {
  105.         frame.pack();
  106.         frame.show();
  107.     }
  108.     return true;
  109.     }
  110. }
  111. @
  112.  
  113.  
  114. 1.2
  115. log
  116. @Added package statement (used by switcher).
  117. @
  118. text
  119. @d15 1
  120. a15 1
  121.     Button button = new Button("What Am I Missing?");
  122. d22 2
  123. d29 14
  124. a42 4
  125.  
  126.     Image image = getImage(getCodeBase(), filename);
  127.     String gifWidth = getParameter("GIFWIDTH");
  128.     String gifHeight = getParameter("GIFHEIGHT");
  129. @
  130.  
  131.  
  132. 1.1
  133. log
  134. @Initial revision
  135. @
  136. text
  137. @d1 2
  138. @
  139.