Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is it possible to show different colors in choice or list box?

 
ankush mehta
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends!
i have a query and i will highly appreciate it if you could help me out.
I WANT TO ADD DIFFERENT ITEMS IN A LIST BOX OR CHOICE BOX.
Is it possible?
I will look forward to your reply.
regards,
ankush
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Foreground and Background colors are set for a complete component. In order to have different colors, each item in the list would need to be a different component. The only way (that I know of) to accomplish this is to use a Tree like perhaps JTree or TreeSet etc.
 
David Shepherd
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to look at " list cell renderer" or list selection models in the javadoc. I have seen people use icons in list boxes (I think) and I believe that each item in a list is a Label object. Obviously, I only have a superficial understanding but I think you can accomplish what you are after. Check out the two areas above in javadoc (Interface ListCellRenderer, DefaultListCellRenderer). I hope that is of some use.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic