Java JTextPane setSelectionFontSize(JTextPane textPane, int fontSize)

Here you can find the source of setSelectionFontSize(JTextPane textPane, int fontSize)

Description

Sets the font size of the selected text.

License

Apache License

Declaration

public static void setSelectionFontSize(JTextPane textPane, int fontSize) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.swing.JTextPane;

import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;

public class Main {
    /**/*  w w w. j av  a  2s .  com*/
     * Sets the font size of the selected text.
     */
    public static void setSelectionFontSize(JTextPane textPane, int fontSize) {
        String FONTFAMILY = "fontSize." + fontSize;
        Style fontSizeStyle = new StyleContext().addStyle(FONTFAMILY, null);
        fontSizeStyle.addAttribute(StyleConstants.FontSize, new Integer(
                fontSize));
        textPane.setCharacterAttributes(fontSizeStyle, false);
    }
}

Related

  1. overrideStyle(String styleName, JTextPane textPane, Style newStyle)
  2. saveFile(JTextPane txt)
  3. scrollTo(JTextPane textPane, int position)
  4. setDefaultTextPaneProperties(JTextPane textPane)
  5. setJTextPaneFont(JTextPane jtp, Font font, Color c)
  6. setSelectionForeground(JTextPane textPane, Color color)
  7. setStyle(JTextPane textPane, int start, int length, String name)
  8. setStyle(JTextPane textPane, Style style)
  9. setTabs(int charactersPerTab, JTextPane textpane)