0

The ComboBox text color is white even though I've set it to black in my theme. The text color of TextField is black as supposed to. How come the ComboBox text color isn't black?

The theme:

fgColor=FFFFFF  
bgColor=000000  
sel#fgColor=FFFFFF  
sel#bgColor=EE8207  
ComboBox.fgColor=000000  
ComboBox.bgColor=FFFFFF  
ComboBox.sel#fgColor=000000  
ComboBox.sel#bgColor=FFFFFF  
TextField.fgColor=000000  
TextField.bgColor=FFFFFF  
TextField.sel#fgColor=000000  
TextField.sel#bgColor=FFFFFF  
AOO
  • 1
  • 1

3 Answers3

1

You can change the text color like this

Style selStyle = UIManager.getInstance().getComponentSelectedStyle("ComboBoxItem");
selStyle.setFgColor(0x00AF00);   // Selected Item will be in green color
UIManager.getInstance().setComponentSelectedStyle("ComboBoxItem", selStyle);

Style unSelStyle = UIManager.getInstance().getComponentStyle("ComboBoxItem");
unSelStyle.setFgColor(0x000000); // Selected Item will be in black color   
UIManager.getInstance().setComponentStyle("ComboBoxItem", unSelStyle);

This will work out!!

0

you can use like this,

ComboBoxItem.fgColor=000000  

ComboBoxItem.sel#fgColor=ffffff

Are you using ResourceEdit. If u r not using means use the ResourceEdit and create the theme.

bharath
  • 14,283
  • 16
  • 57
  • 95
  • Thanks for your tip but it doesn't work for me :S. Can't find any references to ComboBoxItem in the LWUIT API. – AOO Nov 24 '10 at 14:11
0

You should use hexColors: "0x000000" or "0xffffff"

You can also set the color in your app using following methods.

lwuit uses int's to set a color, to calculate the int use the following function.

public static int colorStringToInt(String hexColor) {
    int color;
    try {
        color = Integer.parseInt(hexColor.substring(2), 16);
        return color;
    } catch (Exception ex) {
        ex.printStackTrace();
        return -1;//no negative colors
    }
}

set the color like this.

int color = AppUtils.colorStringToInt("0xffffff");//white
if (color != -1) {
    b.getStyle().setFgColor(color, true);
}
Demian Kasier
  • 2,475
  • 6
  • 30
  • 40