Here you can find the source of initHtmlComponent(JEditorPane editorPane)
public static void initHtmlComponent(JEditorPane editorPane)
//package com.java2s; //License from project: Apache License import javax.swing.*; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; public class Main { public static void initHtmlComponent(JEditorPane editorPane) { editorPane.setContentType("text/html"); editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); HTMLEditorKit kit = (HTMLEditorKit) editorPane.getEditorKit(); StyleSheet css = kit.getStyleSheet(); css.addRule("h1 { font-size:16;font-weight:bold; }"); css.addRule("h2 { font-size:14;font-weight:bold; margin-bottom:0px; }"); css.addRule("p { margin-top:4px; margin-bottom:4px;margin-left:0;margin-right:0;}"); css.addRule("table { border:none; }"); css.addRule("td { vertical-align:top;}"); }/* w w w . ja v a 2 s .co m*/ }