ComboBox Textcolor


is it possible to change the color of text in a ComboBox?
For example, on the basis of parameters.
If the parameter is 0 then the text will be blue color, with 1 red, etc.

To change the text color you have to use css (especially the font-color parameter).
To do this dynamically you can use CssInject. For Vaadin 7 see
For Vaadin 6
If you need it very simple you can just make two different styles and exchange them when the parameter (the one you’re talking about) changes.

Hello Marius,

for our ComboBox we uses a Container.


I do not know what to do I could start a css change.
I shall need but a corresponding listener, right?
Which would then be attached to this point?

Thanks for your help!


I don’t quite understand what you’re trying to do here.

If you want to listen to the user selecting items in the combobox you have to use a ValuechangeListener (Combobox in immediate mode)

To change the style of an object inside java you should use the Combobox.setStyleName(“styleclass”) method corresponding to style class in your style.css (Vaadin 6). When using the CssInject, either the addon for Vaadin 6 or the built-in version of vaadin 7, you can create/add style classes at runtime.

If you want,you could open a thread in the German discussion chapter if that would makes it easier for you to explain your problem.

Ok. I will do that.