aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes is it possible to show different colors in choice or list box? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "is it possible to show different colors in choice or list box?" Watch "is it possible to show different colors in choice or list box?" New topic
Author

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

ankush mehta
Greenhorn

Joined: Feb 08, 2001
Posts: 20
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

Joined: Sep 29, 2000
Posts: 8521
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.


"JavaRanch, where the deer and the Certified play" - David O'Meara
David Shepherd
Ranch Hand

Joined: Mar 02, 2001
Posts: 35
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is it possible to show different colors in choice or list box?