List of usage examples for javax.swing JEditorPane getEditorKitForContentType
public EditorKit getEditorKitForContentType(String type)
From source file:Main.java
public static void setPaneHtmlText(String htmlText, JEditorPane pane) { if (htmlText == null) { pane.setText(""); return;/*from w w w.j av a 2s . c o m*/ } else if (htmlText.length() == 0) { pane.setText(""); return; } StringReader htmReader = new StringReader(htmlText); HTMLEditorKit kit = (HTMLEditorKit) pane.getEditorKitForContentType("text/html"); HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); ParserDelegator parser = new ParserDelegator(); try { parser.parse(htmReader, doc.getReader(0), true); } catch (IOException ex) { ex.printStackTrace(); } pane.setDocument(doc); }