Here you can find the source of installTextStyle(JEditorPane control, String styleName)
Parameter | Description |
---|---|
control | text control. |
styleName | style name. |
public static void installTextStyle(JEditorPane control, String styleName)
//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); } }