Hi,
I use this code to underline text in a JTextPane:
SimpleAttributeSet attributes = new SimpleAttributeSet();
StyleConstants.setUnderline(attributes, true);
StyledDocument document = getStyledDocument();
document.setCharacterAttributes(0, getText().length(), attributes,
true);
How can I change the color of the line? By default the color is the same as
the text color...
Thanks.
René
Christian Kaufhold - 13 May 2005 14:17 GMT
> SimpleAttributeSet attributes = new SimpleAttributeSet();
> StyleConstants.setUnderline(attributes, true);
[quoted text clipped - 4 lines]
> How can I change the color of the line? By default the color is the same as
> the text color...
Not so easy. The painting is done in GlyphView.paintTextUsingColor (which is
package-private) and always in the same color as the text.
It will need a lot of rewriting to replace it.
At least underlining is not done by TextLayout, where there is no control
over the color (or style) at all.
Christian