Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified
Accepted Solution

Change text color of CheckboxField?

Hi All

 

I want to change the label text color of my Checkboxfield from default black to white. How can this be achieved?

 

Thanks

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Change text color of CheckboxField?

Try overriding the paint() method and changing the colors.

 

Highlighted
Trusted Contributor
Posts: 224
Registered: ‎08-11-2010
My Device: Not Specified

Re: Change text color of CheckboxField?

class ColorCheckBoxField extends CheckboxField
{
  public ColorCheckBoxField(String label, boolean value, long style)
  {
    super(label, value, style);
  }
  public ColorCheckBoxField(String label, boolean value)
  {
    super(label, value, 0);
  }
  protected void paint(Graphics g)
  {
    if (getVisualState() == VISUAL_STATE_FOCUS)
    {
      int c = g.getColor();
      g.setColor(Color.BLUE);
      g.fillRect(0, 0, getWidth(), getHeight());
      g.fillRect(0, 0, 2000, getHeight());
      g.setColor(c);
    }
    g.setColor(Color.WHITE);
    super.paint(g);
  }

  protected void applyTheme(Graphics arg0, boolean arg1)
  {
  }
}

 

This is a code used in production app, you can fine tune it.