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
New Developer
Posts: 18
Registered: ‎09-18-2008
My Device: Not Specified

LabelField bitmap background

Is it possible to set a bitmap as the background for a labelfield rather than using a color?

 

If not, is there a workarounf for simulating this?

 

Thanks

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: LabelField bitmap background

sure, you can overwrite the labelfields paint method.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: LabelField bitmap background

Try something like this...

 

Bitmap _bitmap = Bitmap.getBitmapResource("img.png"); LabelField lf = new LabelField("Test",LabelField.USE_ALL_HEIGHT|LabelField.USE_ALL_WIDTH) { public void paint(Graphics g) { g.drawBitmap(0,0, g.getScreenWidth(), g.getScreenHeight(),_bitmap, 0,0); super.paint(g); } }; add(lf);

 

 

 


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 18
Registered: ‎09-18-2008
My Device: Not Specified

Re: LabelField bitmap background

Sweet.  But one problem.  It only paints the labelfield background where there is text.  Any way to get it to fill the entire field?

 

Thanks

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: LabelField bitmap background

fill the entier field by other color? Do the changes in your paint method.

Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 18
Registered: ‎09-18-2008
My Device: Not Specified

Re: LabelField bitmap background

Thanks BBDeveloper.  You'll have to excue me, I'm new to JDE.  Happy to work this out but could do with a pointer on what to read up on to get the bitmap to fill the entire field using the paint method.
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: LabelField bitmap background

Use the Image with the width and height of the LabelField, or scale the image to teh desired width and height and use it.

Use Search. "Accept Solution" If the problem is resolved.
Highlighted
Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: LabelField bitmap background

Worth going thru this thread

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=13264

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group