home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / applet / AppletViewerPanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.7 KB  |  100 lines

  1. package sun.applet;
  2.  
  3. import java.applet.AppletContext;
  4. import java.awt.Component;
  5. import java.net.MalformedURLException;
  6. import java.net.URL;
  7. import java.util.Hashtable;
  8.  
  9. class AppletViewerPanel extends AppletPanel {
  10.    static boolean debug;
  11.    URL documentURL;
  12.    URL baseURL;
  13.    Hashtable atts;
  14.  
  15.    AppletViewerPanel(URL var1, Hashtable var2) {
  16.       this.documentURL = var1;
  17.       this.atts = var2;
  18.       String var3 = this.getParameter("codebase");
  19.       if (var3 != null) {
  20.          if (!var3.endsWith("/")) {
  21.             var3 = var3 + "/";
  22.          }
  23.  
  24.          try {
  25.             this.baseURL = new URL(var1, var3);
  26.          } catch (MalformedURLException var7) {
  27.          }
  28.       }
  29.  
  30.       if (this.baseURL == null) {
  31.          String var4 = var1.getFile();
  32.          int var5 = var4.lastIndexOf(47);
  33.          if (var5 > 0 && var5 < var4.length() - 1) {
  34.             try {
  35.                this.baseURL = new URL(var1, var4.substring(0, var5 + 1));
  36.             } catch (MalformedURLException var6) {
  37.             }
  38.          }
  39.       }
  40.  
  41.       if (this.baseURL == null) {
  42.          this.baseURL = var1;
  43.       }
  44.  
  45.    }
  46.  
  47.    public String getParameter(String var1) {
  48.       return (String)this.atts.get(var1.toLowerCase());
  49.    }
  50.  
  51.    public URL getDocumentBase() {
  52.       return this.documentURL;
  53.    }
  54.  
  55.    public URL getCodeBase() {
  56.       return this.baseURL;
  57.    }
  58.  
  59.    public int getWidth() {
  60.       String var1 = this.getParameter("width");
  61.       return var1 != null ? Integer.valueOf(var1) : 0;
  62.    }
  63.  
  64.    public int getHeight() {
  65.       String var1 = this.getParameter("height");
  66.       return var1 != null ? Integer.valueOf(var1) : 0;
  67.    }
  68.  
  69.    public String getCode() {
  70.       return this.getParameter("code");
  71.    }
  72.  
  73.    public String getJarFiles() {
  74.       return this.getParameter("archive");
  75.    }
  76.  
  77.    public String getSerializedObject() {
  78.       return this.getParameter("object");
  79.    }
  80.  
  81.    public AppletContext getAppletContext() {
  82.       return (AppletContext)((Component)this).getParent();
  83.    }
  84.  
  85.    static void debug(String var0) {
  86.       if (debug) {
  87.          System.err.println("AppletViewerPanel:::" + var0);
  88.       }
  89.  
  90.    }
  91.  
  92.    static void debug(String var0, Throwable var1) {
  93.       if (debug) {
  94.          var1.printStackTrace();
  95.          debug(var0);
  96.       }
  97.  
  98.    }
  99. }
  100.