Java JTextPane setStyle(JTextPane textPane, int start, int length, String name)

Here you can find the source of setStyle(JTextPane textPane, int start, int length, String name)

Description

set Style

License

Open Source License

Declaration

public static void setStyle(JTextPane textPane, int start, int length, String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JTextPane;

import javax.swing.text.Style;

import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;

public class Main {
    public static void setStyle(JTextPane textPane, int start, int length, String name) {
        StyledDocument doc = textPane.getStyledDocument();
        Style style;/*from  ww  w . ja  v  a2 s. c o m*/
        if (name == null) {
            StyleContext context = StyleContext.getDefaultStyleContext();
            style = context.getStyle(StyleContext.DEFAULT_STYLE);
        } else
            style = doc.getStyle(name);
        doc.setCharacterAttributes(start, length, style, true);
    }
}

Related

  1. scrollTo(JTextPane textPane, int position)
  2. setDefaultTextPaneProperties(JTextPane textPane)
  3. setJTextPaneFont(JTextPane jtp, Font font, Color c)
  4. setSelectionFontSize(JTextPane textPane, int fontSize)
  5. setSelectionForeground(JTextPane textPane, Color color)
  6. setStyle(JTextPane textPane, Style style)
  7. setTabs(int charactersPerTab, JTextPane textpane)
  8. setTextToPane(JTextPane textPane, String text, Color foregroundColor, Color backgroundColor)
  9. writeImage(final JTextPane jtPane, final ImageIcon msg)