I have a JList and inside that list, I want to change the color of the font of the following words.
Someone said that I have to use CellRenderer but I'm not yet familiar with that.
Now, my problem is how can I setup this renderer to change the color of the Font?
Any idea about this matter?
Thanks...
Check out the JavaDoc, it might just have what you need (the example at the top). Basically you just return a component (like a JLabel) with a configured font color.
Edit: since you want to have the words in a different color than their definitions, here two possibilities how that can be done with the list cell renderer:
<html><font color=red>your word</font> - your definitions</html>
. Note that the default foreground color should then be the one for the definitions, alternatively you can wrap the definitions with a <font>
tag as well. Have a look at this Tutorial.