7272import javax .swing .text .html .HTMLEditorKit ;
7373
7474import swingjs .JSHTMLHelper ;
75+ import swingjs .JSUtil ;
7576//import swingjs.JSAbstractDocument;
7677import swingjs .api .Interface ;
7778//import swingjs.api.JSMinimalAbstractDocument;
@@ -423,6 +424,7 @@ public void fireHyperlinkUpdate(HyperlinkEvent e) {
423424 * @see #getPage
424425 * @beaninfo description: the URL used to set content bound: true expert: true
425426 */
427+ @ SuppressWarnings ("unused" )
426428 public void setPage (URL page ) throws IOException {
427429 if (page == null ) {
428430 throw new IOException ("invalid url" );
@@ -464,6 +466,7 @@ public void setPage(URL page) throws IOException {
464466 // load asynchronously
465467 setDocument (doc );
466468 synchronized (this ) {
469+ 秘setPage (doc , page );
467470 loading = new PageStream (in );
468471 Thread pl = new PageLoader (doc , loading , p , loaded , page );
469472 pl .start ();
@@ -472,6 +475,7 @@ public void setPage(URL page) throws IOException {
472475 }
473476 read (in , doc );
474477 setDocument (doc );
478+ 秘setPage (doc , page );
475479 reloaded = true ;
476480 }
477481 } else {
@@ -501,6 +505,16 @@ public void run() {
501505 firePropertyChange ("page" , loaded , page );
502506 }
503507
508+ private void 秘setPage (Document doc , URL page ) {
509+ if (doc instanceof HTMLDocument ) {
510+ byte [] bytes = JSUtil .getBytes (page );
511+ if (bytes != null ) {
512+ if (秘jsHTMLHelper != null )
513+ 秘jsHTMLHelper .setText (new String (bytes ));
514+ }
515+ }
516+ }
517+
504518 /**
505519 * Create model and initialize document properties from page properties.
506520 */
@@ -1225,6 +1239,7 @@ public static EditorKit createEditorKitForContentType(String type) {
12251239 // try to dynamically load the support
12261240 String classname = (String ) getKitTypeRegistry ().get (type );
12271241// ClassLoader loader = (ClassLoader) getKitLoaderRegistry().get(type);
1242+ if (classname != null )
12281243 try {
12291244 k = (EditorKit ) Interface .getInstance (classname , false );
12301245// Class c;
@@ -1436,12 +1451,7 @@ public void setText(String t) {
14361451 try {
14371452 Document doc = getDocument ();
14381453 if (doc instanceof HTMLDocument ) {
1439- if (t .indexOf ("<body" )< 0 )
1440- t = "<body>" + t + "</body>" ;
1441- if (t .indexOf ("<head" )< 0 )
1442- t = "<head>" + t + "</head>" ;
1443- if (t .indexOf ("<html" )< 0 )
1444- t = "<html>" + t + "</html>" ;
1454+ t = 秘fixHTML (t );
14451455 }
14461456 if (秘jsHTMLHelper != null )
14471457 秘jsHTMLHelper .setText (t );
@@ -1459,6 +1469,16 @@ public void setText(String t) {
14591469 }
14601470 }
14611471
1472+ private static String 秘fixHTML (String t ) {
1473+ if (t .indexOf ("<body" )< 0 )
1474+ t = "<body>" + t + "</body>" ;
1475+ if (t .indexOf ("<head" )< 0 )
1476+ t = "<head>" + t + "</head>" ;
1477+ if (t .indexOf ("<html" )< 0 )
1478+ t = "<html>" + t + "</html>" ;
1479+ return t ;
1480+ }
1481+
14621482 /**
14631483 * Returns the text contained in this <code>TextComponent</code> in terms of the
14641484 * content type of this editor. If an exception is thrown while attempting to
0 commit comments