[英]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. 我正在编写一个文本比较工具,并希望显示在Red中不相同的字符。
Thatfor I have to change the Color (with setForeground()
?) of a Passage of the Text. 因为我必须更改文本段落的颜色(使用
setForeground()
?)。
How can I do that? 我怎样才能做到这一点?
Instead of labels you will need to use a JEditorPane as your rendering component. 您需要使用JEditorPane作为渲染组件,而不是标签。
Look here for inspiration: How to insert JEditorPane into JTable cell? 在这里寻找灵感: 如何将JEditorPane插入JTable单元格?
您可以使用“<html>一些文本<font color ...> some text </ font> </ html>”作为单元格的文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.