Neifen
Neifen

Reputation: 2595

How to change the Color of a text Passage in a JTable?

I'm writing a Text comparing tool and would like to show the charaters who are not same in Red.
Thatfor I have to change the Color (with setForeground()?) of a Passage of the Text.
How can I do that?

Upvotes: 0

Views: 142

Answers (2)

StanislavL
StanislavL

Reputation: 57381

You can use "< html>Some text< font color...>some text< /font>< /html>" for the cell's text.

Upvotes: 1

Stijn Geukens
Stijn Geukens

Reputation: 15628

Instead of labels you will need to use a JEditorPane as your rendering component.

Look here for inspiration: How to insert JEditorPane into JTable cell?

Upvotes: 1

Related Questions