Paul Reiners
Paul Reiners

Reputation: 7894

Setting font color on DefaultStyledDocument

I know that I can set the font size on a javax.swing.text.DefaultStyledDocument like this:

public void apply(DefaultStyledDocument document) {
    final MutableAttributeSet attributeSet = new SimpleAttributeSet();
    StyleConstants.setFontSize(attributeSet, 12);
    document.setCharacterAttributes(0, 80, attributeSet, false);
}

How do I set the font color?

Upvotes: 1

Views: 661

Answers (1)

camickr
camickr

Reputation: 324157

I would guess you use the StyleConstants.setForeground(...) method.

Upvotes: 1

Related Questions