예제 #1
0
 public static void clearAll(JEditorPane txt) {
   try {
     txt.setText("");
     HTMLEditorKit kit = (HTMLEditorKit) txt.getEditorKit();
     HTMLDocument doc = (HTMLDocument) txt.getDocument();
     kit.insertHTML(
         doc, 0, "<body style=\"font-family:'Courier New';font-size: 12pt;\">", 0, 0, null);
   } catch (Exception e) {
   }
 }
예제 #2
0
 private static void appendHTML(JEditorPane editor, String html) {
   try {
     html = StringUtil.replaceAll(html, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
     html = StringUtil.replaceAll(html, "\r\n", "\n");
     html = StringUtil.replaceAll(html, "\r", "");
     Vector vt = StringUtil.toStringVector(html, "\n");
     HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
     HTMLDocument doc = (HTMLDocument) editor.getDocument();
     for (int iIndex = 0; iIndex < vt.size(); iIndex++)
       kit.insertHTML(doc, doc.getLength(), (String) vt.elementAt(iIndex), 0, 0, null);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }