@@ -1324,14 +1324,11 @@ private static void loadDefaultKitsIfNecessary() {
13241324 if (SwingUtilities .appContextGet (kitTypeRegistryKey ) == null ) {
13251325 synchronized (defaultEditorKitMap ) {
13261326 if (defaultEditorKitMap .size () == 0 ) {
1327- // preliminary only - no support for rtf; html same as plain
13281327 defaultEditorKitMap .put ("text/plain" , "javax.swing.JEditorPane$PlainEditorKit" );
1329- defaultEditorKitMap .put ("text/html" , "javax.swing.JEditorPane$PlainEditorKit" );
1330-
1331- //defaultEditorKitMap.put("text/plain", "javax.swing.JEditorPane$PlainEditorKit");
1332- //defaultEditorKitMap.put("text/html", "javax.swing.text.html.HTMLEditorKit");
1333- //defaultEditorKitMap.put("text/rtf", "javax.swing.text.rtf.RTFEditorKit");
1334- //defaultEditorKitMap.put("application/rtf", "javax.swing.text.rtf.RTFEditorKit");
1328+ defaultEditorKitMap .put ("text/html" , "javax.swing.text.html.HTMLEditorKit" );
1329+ // SwingJS
1330+ // defaultEditorKitMap.put("text/rtf", "javax.swing.text.rtf.RTFEditorKit");
1331+ // defaultEditorKitMap.put("application/rtf", "javax.swing.text.rtf.RTFEditorKit");
13351332
13361333 }
13371334 }
@@ -1437,9 +1434,17 @@ public Dimension getPreferredSize() {
14371434 @ Override
14381435 public void setText (String t ) {
14391436 try {
1437+ Document doc = getDocument ();
1438+ 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>" ;
1445+ }
14401446 if (秘jsHTMLHelper != null )
14411447 秘jsHTMLHelper .setText (t );
1442- Document doc = getDocument ();
14431448 doc .remove (0 , doc .getLength ());
14441449 if (t == null || t .equals ("" )) {
14451450 return ;
0 commit comments