MorFe
MorFe

Reputation: 1

how can i display text in different colors in a jtextPane

i want to display a text in a jtextPane but on each time i want it to be with a different color without changing the previous text color if that possible Any help will be appreciated thank's in advance

Upvotes: 0

Views: 31

Answers (1)

Sharcoux
Sharcoux

Reputation: 6115

You can use StyledEditorKit.ForegroundAction, but also StyledDocument.setCharacterAttributes , or edit the inputAttributes from StyledDocument.getInputAttributes. You can use StyleConstants.setForeground to edit a MuttableAttributeSet like a SimpleAttributeSet for instance.

Upvotes: 1

Related Questions