• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multi-Colored JList

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JList that is updated with a thread every 5 minutes with current open trouble tickets. The trouble tickets can be one of three types
1. unaccepted
2. accepted
3. closed
I was wondering if there was a way to have the three different trouble ticket types to be 3 different colors inside my JList.
Thanks for any help.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the ListCellRenderer example in the API doco. It is using an icon but you can do what you want. Same concept as for tables. In fact the renderer extends JLabel.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, I will take a look at it. I may be able to just use an Icon instead of coloring the text anyway.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, just wanted to let you know that I got it working. Thanks for your help.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. Did you go with the color or icons?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went with the color. I needed something that was a little more "First Glance" and I think colors works out better for that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!