Java JEditorPane installTextStyle(JEditorPane control, String styleName)

Here you can find the source of installTextStyle(JEditorPane control, String styleName)

Description

Puts the text style over the text in current document.

License

Open Source License

Parameter

Parameter Description
control text control.
styleName style name.

Declaration

public static void installTextStyle(JEditorPane control, String styleName) 

Method Source Code


//package com.java2s;
// the terms of the GNU General Public License as published by the Free Software Foundation;

import javax.swing.*;

import javax.swing.text.html.HTMLDocument;

public class Main {
    /**/*from  ww  w .j  a  v a 2s  . co m*/
     * Puts the text style over the text in current document.
     *
     * @param control   text control.
     * @param styleName style name.
     */
    public static void installTextStyle(JEditorPane control, String styleName) {
        HTMLDocument doc = (HTMLDocument) control.getDocument();
        doc.setCharacterAttributes(0, control.getDocument().getLength(), doc.getStyle(styleName), false);
    }
}

Related

  1. enforceJEditorPaneFont(JEditorPane jEditorPane, Font font)
  2. formatEditorPaneAsLabel(JEditorPane editor)
  3. getEditor(JEditorPane editor, String html, int width, Color transparentColor, Font font)
  4. getImage(JEditorPane editor, Color transparentColor)
  5. initHtmlComponent(JEditorPane editorPane)
  6. panelForHtml(JEditorPane editorPane)
  7. scrollToTop(final JEditorPane editor)
  8. scrollToTop(JEditorPane editor)
  9. setDefaultFontToEditorPane(JEditorPane editor, boolean justify)