set items color in JCombo box
Hi, I would like to custom the items color (background/ foreground) in a combo box. How can I do ? I think I have to write a self render component right? But could some of you give me some examples? Thanks for help.
# 1
JComboBox uses ListCellRenderer, so you can either implement this interface or extend the javax.swing.DefaultListCellRenderer class, second option will be easier.
Also visit http://java.sun.com/developer/technicalArticles/GUI/jlist/index.html I think going thru this will solve your problem.
# 2
> But could some of you give me some examples?Sure, search the forum for examples or read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html#renderer]How to Use Combo Boxes[/url] for an example.