1180 * @return the editor kit, or <code>null</code> if there is nothing
1181 * registered for the given type
1182 */
1183 public static EditorKit createEditorKitForContentType(String type) {
1184 Hashtable<String, EditorKit> kitRegistry = getKitRegisty();
1185 EditorKit k = kitRegistry.get(type);
1186 if (k == null) {
1187 // try to dynamically load the support
1188 String classname = getKitTypeRegistry().get(type);
1189 ClassLoader loader = getKitLoaderRegistry().get(type);
1190 try {
1191 Class<?> c;
1192 if (loader != null) {
1193 ReflectUtil.checkPackageAccess(classname);
1194 c = loader.loadClass(classname);
1195 } else {
1196 // Will only happen if developer has invoked
1197 // registerEditorKitForContentType(type, class, null).
1198 c = SwingUtilities.loadSystemClass(classname);
1199 }
1200 k = (EditorKit) c.newInstance();
1201 kitRegistry.put(type, k);
1202 } catch (Throwable e) {
1203 k = null;
1204 }
1205 }
1206
1207 // create a copy of the prototype or null if there
1208 // is no prototype.
1209 if (k != null) {
1210 return (EditorKit) k.clone();
1211 }
1212 return null;
1213 }
1214
1215 /**
1216 * Establishes the default bindings of <code>type</code> to
1217 * <code>classname</code>.
1218 * The class will be dynamically loaded later when actually
1219 * needed, and can be safely changed before attempted uses
1220 * to avoid loading unwanted classes. The prototype
|
1180 * @return the editor kit, or <code>null</code> if there is nothing
1181 * registered for the given type
1182 */
1183 public static EditorKit createEditorKitForContentType(String type) {
1184 Hashtable<String, EditorKit> kitRegistry = getKitRegisty();
1185 EditorKit k = kitRegistry.get(type);
1186 if (k == null) {
1187 // try to dynamically load the support
1188 String classname = getKitTypeRegistry().get(type);
1189 ClassLoader loader = getKitLoaderRegistry().get(type);
1190 try {
1191 Class<?> c;
1192 if (loader != null) {
1193 ReflectUtil.checkPackageAccess(classname);
1194 c = loader.loadClass(classname);
1195 } else {
1196 // Will only happen if developer has invoked
1197 // registerEditorKitForContentType(type, class, null).
1198 c = SwingUtilities.loadSystemClass(classname);
1199 }
1200 @SuppressWarnings("deprecation")
1201 Object tmp = c.newInstance();
1202 k = (EditorKit) tmp;
1203 kitRegistry.put(type, k);
1204 } catch (Throwable e) {
1205 k = null;
1206 }
1207 }
1208
1209 // create a copy of the prototype or null if there
1210 // is no prototype.
1211 if (k != null) {
1212 return (EditorKit) k.clone();
1213 }
1214 return null;
1215 }
1216
1217 /**
1218 * Establishes the default bindings of <code>type</code> to
1219 * <code>classname</code>.
1220 * The class will be dynamically loaded later when actually
1221 * needed, and can be safely changed before attempted uses
1222 * to avoid loading unwanted classes. The prototype
|