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: 83
Registered: ‎03-11-2009
My Device: Not Specified
Accepted Solution

setBackgroundColor for LabelField

Hi,

 

Is there any way that I can setBackground color of the LabelField on demand?! I mean I want to change the color of the LabelField after creating it, not using paintBackground (because paintBackground only sets the background once and cannot be changed later)

 

Thanks

http://geekswithblogs.net/interfacemirror
Together there is no mountain we can’t climb!
Highlighted
Developer
Posts: 174
Registered: ‎08-20-2008
My Device: Not Specified

Re: setBackgroundColor for LabelField

I would extend the LabelField and override the the paintBackground method but set the colour to a variable such as bgColour. The create a method like the one below.

 

public void setBgColour(int bgColour)

{

     this.bgColour = this.bgColour;

     invalidate(); // Will cause the field to repaint

}

Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: setBackgroundColor for LabelField

public void setBgColour(int bgColour)

{ this.bgColour = bgColour; invalidate(); // Will cause the field to repaint}

 Small correction in the code presented in the previous post.


Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 83
Registered: ‎03-11-2009
My Device: Not Specified

Re: setBackgroundColor for LabelField

Baskar,

 

WHat was the change? The code you placed is exactly same as the old post!

http://geekswithblogs.net/interfacemirror
Together there is no mountain we can’t climb!
Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: setBackgroundColor for LabelField

In the previous post, look at the following code:

 

this.bgColour = this.bgColour;

 

In the above code, the same global variable is assigned to itself. The method parameter was not even considered.

 

Hence, I have assigned the method parameter bgColour to the global variable this.bgColour as below:

 

 this.bgColour =bgColour;


Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 83
Registered: ‎03-11-2009
My Device: Not Specified

Re: setBackgroundColor for LabelField

Baskar,

 

Thank you for the sharp notice. I thought your modification was Formatting the code only Smiley Very Happy Smiley Very Happy Smiley Very Happy Smiley Very Happy .

http://geekswithblogs.net/interfacemirror
Together there is no mountain we can’t climb!
Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: setBackgroundColor for LabelField

Thank God, you didn't thought that even my Code Formatting was not proper! Smiley Tongue

 

 While inserting code using "Insert Code" option while posting, its not keeping the proper format of the inserted code!! :smileysurprised:


Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 174
Registered: ‎08-20-2008
My Device: Not Specified

Re: setBackgroundColor for LabelField

Cheers for the correction was the end of a long day Smiley Wink