views:

43

answers:

1

Hi, I have a doubt on Jcombobox... for example, i have a gui which contains a jcombo box and a button... In Jcombo box ,i have added string array object like color 1,color 2 ,color 3: String[] colors = {"Color 1","Color 2","Color 3"}.and i can select color when clicked the button by using of colorchooser and it will apply into the button only.... But i want to setforeground color to "Color 1" ,"Color 2" in tat combo box.. for ex: if i select color as red through button,it should be applied foreground color on jcombobox only " SELECTED ITEM" only(example Color 1 should be displayed as RED,others should be default color!

...I am new one to Java...if anyone knows,plz help me.. Thanks

+3  A: 

You can provide your own renderer to the JComboBox by implementing ListCellRenderer.

See http://download.oracle.com/javase/tutorial/uiswing/components/combobox.html#renderer

Qwerky