简体   繁体   中英

JList text color

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM