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) { } }