StyleConstants: setUnderline(MutableAttributeSet a, boolean b) : StyleConstants « javax.swing.text « Java by API






StyleConstants: setUnderline(MutableAttributeSet a, boolean b)

  

import java.awt.Color;

import javax.swing.JTextPane;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

public class Main {
  public static void main(String[] argv) throws Exception {
    JTextPane textPane = new JTextPane();
    StyledDocument doc = textPane.getStyledDocument();

    Style style = textPane.addStyle("Red", null);
    StyleConstants.setForeground(style, Color.red);

    // Inherits from "Red"; makes text red and underlined
    style = textPane.addStyle("Red Underline", style);
    StyleConstants.setUnderline(style, true);
  }
}

   
    
  








Related examples in the same category

1.StyleConstants.Bold
2.StyleConstants.Foreground
3.StyleConstants.Italic
4.StyleConstants.LineSpacing
5.StyleConstants: setAlignment(MutableAttributeSet a, int align)
6.StyleConstants: setBold(MutableAttributeSet a, boolean b)
7.StyleConstants: setComponent(MutableAttributeSet a, Component c)
8.StyleConstants: setFirstLineIndent(MutableAttributeSet a, float i)
9.StyleConstants: setFontFamily(MutableAttributeSet a, String fam)
10.StyleConstants: setForeground(MutableAttributeSet a, Color fg)
11.StyleConstants: setFontSize(MutableAttributeSet a, int s)
12.StyleConstants: setIcon(MutableAttributeSet a, Icon c)
13.StyleConstants: setItalic(MutableAttributeSet a, boolean b)
14.StyleConstants: setLeftIndent(MutableAttributeSet a, float i)
15.StyleConstants: setRightIndent(MutableAttributeSet a, float i)
16.StyleConstants: setSpaceAbove(MutableAttributeSet a, float i)
17.StyleConstants: setSpaceBelow(MutableAttributeSet a, float i)
18.StyleConstants: setTabSet(MutableAttributeSet a, TabSet tabs)