< prev index next >

src/java.desktop/share/classes/javax/swing/JEditorPane.java

Print this page




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




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


< prev index next >