I am developing a an app where in i use a combobox.
i like to change the font size and backgroundcolor of the combobox and de comboboxpopup. How do i do this, without css.
in the theme.res i can change the backgrondcolor of the comboboxpopup but not of the combobox. This stays grey, also when i changed the color in theme.res.
Also with code it doesn't change. What is the right way, can somebody give me an example.
combotijden.getAllStyles().setBorder(Border.createEmpty(),true);
combotijden.getAllStyles().setBgColor(0xffa500, true);
combotijden.getAllStyles().setFgColor(0xFFFFFF, true);
A ComboBox
is a List
and as a result uses a renderer to draw itself. You need to style the renderer and not just the ComboBox
. Easiest way is possibly:
Style rendererStyle = ((Component)combo.getRenderer()).getAllStyles();
This is pretty bad form since I rely on the fact that the DefaultCellRenderer
is a component. That's part of why we recommend using a Picker
but that is even less customizable. See this post for more alternatives.
BTW instead of hardcoding numbers it's often best to just invoke setUIID(String)
and then have several pre-configured looks in the CSS. That way you can still keep the theme separate and configurable.