1 16 package org.mortbay.html; 17 18 import java.io.IOException ; 19 import java.io.Writer ; 20 import java.util.Enumeration ; 21 import java.util.Hashtable ; 22 23 24 40 public class Applet extends Block 41 { 42 43 public String codeBase = null; 44 45 46 private boolean debug =false; 47 private Hashtable params = null; 48 private Composite paramHolder = new Composite(); 49 50 51 54 public Applet(String className) 55 { 56 super("applet"); 57 add(paramHolder); 58 attribute("code",className); 59 } 60 61 62 64 public Applet setDimensions(int height, int width) 65 { 66 width(width); 67 height(height); 68 return this; 69 } 70 71 72 76 public Applet setDebug(boolean debug){ 77 this.debug = debug; 78 return this; 79 } 80 81 82 87 public Applet setAlternate(Element alt) 88 { 89 add(alt); 90 return this; 91 } 92 93 94 98 public Applet setAlternate(String alt) 99 { 100 add(alt); 101 return this; 102 } 103 104 105 106 public Applet codeBase(String cb) 107 { 108 codeBase = cb; 109 return this; 110 } 111 112 113 public Applet setParam(String name, String value) 114 { 115 if (params == null) 116 params = new Hashtable (10); 117 params.put(name, value); 118 return this; 119 } 120 121 122 123 public void write(Writer out) 124 throws IOException 125 { 126 if (codeBase != null) 127 attribute("codebase",codeBase); 128 129 if (debug) 130 paramHolder.add("<param name=\"debug\" value=\"yes\">"); 131 if (params != null) 132 for (Enumeration enm = params.keys(); enm.hasMoreElements();) 133 { 134 String key = enm.nextElement().toString(); 135 paramHolder.add("<param name=\"" + key + "\" value=\"" + 136 params.get(key).toString() + "\">"); 137 } 138 super.write(out); 139 } 140 }; 141 142 143 144 145 146 | Popular Tags |