JEditorPane (@Nullable Consumer<? super View> imageViewHandler) { HTMLEditorKit kit = new HTMLEditorKitBuilder().withViewFactoryExtensions((e, view) -> { if (view instanceof ParagraphView) { return new ParagraphView(e) { { super.setLineSpacing(0.3f); } @Override protected void setLineSpacing(float ls) { } }; } if (imageViewHandler != null && view instanceof ImageView) { imageViewHandler.accept(view); } return view; }).build(); StyleSheet sheet = kit.getStyleSheet(); sheet.addRule("ul { margin-left-ltr: 30; margin-right-rtl: 30; }"); sheet.addRule("a { color: " + ColorUtil.toHtmlColor(JBUI.CurrentTheme.Link.Foreground.ENABLED) + "; }"); sheet.addRule("h4 { font-weight: bold; }"); sheet.addRule("strong { font-weight: bold; }"); sheet.addRule("p { margin-bottom: 6px; }"); Font font = StartupUiUtil.getLabelFont(); int size = font.getSize(); sheet.addRule("h3 { font-size: " + (size + 3) + "; font-weight: bold; }"); sheet.addRule("h2 { font-size: " + (size + 5) + "; font-weight: bold; }"); sheet.addRule("h1 { font-size: " + (size + 9) + "; font-weight: bold; }"); sheet.addRule("h0 { font-size: " + (size + 12) + "; font-weight: bold; }"); JEditorPane editorPane = new JEditorPane(); editorPane.setEditable(false); editorPane.setOpaque(false); editorPane.setBorder(null); editorPane.setContentType("text/html"); editorPane.setEditorKit(kit); editorPane.addHyperlinkListener(HelpIdAwareLinkListener.getInstance()); return editorPane; }