Emphasize StyleConstant in a different color with AttributeSet

I use spell checking and wonder if there is a simple / obvious way to emphasize some text in a different color such as red.

Everything is set up for me and is emphasized by the following code (the text color is also set):

private AttributeSet getAttributeSet(Color foregroundColor) {
    SimpleAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setForeground(attrs, foregroundColor);
    StyleConstants.setUnderline(attrs, true);
}

The code above sets the word in blue, but also underlines it in blue. I need to change the underline as well as its thickness. Any ideas?

Thank,

+1
source share
1 answer

Use for example this http://java-sl.com/tip_colored_strikethrough.html

Just change it a bit to achieve underlining rather than strikethrough.

, ,

. http://www.java2s.com/Code/Java/Swing-JFC/JTextPaneHighlightExample.htm

+5

All Articles