Question

Is there a way to change the text color of a specific element on a JList?

like this:

one(Black)

two(Blue)

three(Black)

four(Blue)

five(Blue)

six(Black)

using a DefaultListModel and the data are coming from a DB...

Was it helpful?

Solution

The model only stores the data, not the color of the data.

You need to render the data differently for each cell. Read the section from the Swing tutorial on Writing a Custom Renderer for more information and an example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top