Alfred
Alfred

Reputation: 1673

Changing String Color in Java

I want to change the color of the string I found from user input in JTextArea. I have been searching through internet but couldn't find a solution. I know JTextPane can handle such kind of styling very easily but I am not familiar with JTextPane and its functions. for example I don't know how to enable word-wrap and line-wrap which I can easily do in a text area.

So is there a way to change the color of a string in JTtextArea?

Upvotes: 0

Views: 954

Answers (1)

OmniOwl
OmniOwl

Reputation: 5709

Either you use a JEditorPane which can take multiple fonts and formats or you set the Background/Foreground colour of your text area.

setForeground(Color Object Here);
setBackground(Color Object Here);

Upvotes: 3

Related Questions