Java JEditorPane initHtmlComponent(JEditorPane editorPane)

Here you can find the source of initHtmlComponent(JEditorPane editorPane)

Description

init Html Component

License

Apache License

Declaration

public static void initHtmlComponent(JEditorPane editorPane) 

Method Source Code

//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*/
}

Related

  1. emptyDoc(JEditorPane pane)
  2. enforceJEditorPaneFont(JEditorPane jEditorPane, Font font)
  3. formatEditorPaneAsLabel(JEditorPane editor)
  4. getEditor(JEditorPane editor, String html, int width, Color transparentColor, Font font)
  5. getImage(JEditorPane editor, Color transparentColor)
  6. installTextStyle(JEditorPane control, String styleName)
  7. panelForHtml(JEditorPane editorPane)
  8. scrollToTop(final JEditorPane editor)
  9. scrollToTop(JEditorPane editor)