Example usage for javax.swing.text.html StyleSheet importStyleSheet

List of usage examples for javax.swing.text.html StyleSheet importStyleSheet

Introduction

In this page you can find the example usage for javax.swing.text.html StyleSheet importStyleSheet.

Prototype

public void importStyleSheet(URL url) 

Source Link

Document

Imports a style sheet from url.

Usage

From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownPreviewEditor.java

public static void setStyleSheet(JEditorPane jEditorPane) {
    HTMLEditorKit htmlKit = new HTMLEditorKit();

    final StyleSheet style = new StyleSheet();

    if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) {
        style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false));
    } else {/*w ww .ja  v  a2 s . c  o m*/
        try {
            style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)),
                    null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    htmlKit.setStyleSheet(style);
    jEditorPane.setEditorKit(htmlKit);
}

From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownPreviewEditor.java

protected void setStyleSheet() {
    if (isRawHtml)
        return;//www .  j  a va 2  s . c  o m

    MultiMarkdownEditorKit htmlKit = new MultiMarkdownEditorKit();

    final StyleSheet style = new MultiMarkdownStyleSheet();

    if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) {
        style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false));
    } else {
        try {
            style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)),
                    null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    htmlKit.setStyleSheet(style);

    jEditorPane.setEditorKit(htmlKit);
}