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
Regular Contributor
Posts: 57
Registered: ‎07-27-2010
My Device: Bold 9700, 9000 and Storm 9520, 9500
My Carrier: SingTel
Accepted Solution

how to call paint method from another program

Hi there,

 

I have a customized BitmapField which I would like to drawText, using graphics.drawText. Previously, i had no problem as i would call setBitmap from the paint method and this would do the drawText. However, it caused an infinite loop problem so i moved it to another function, which will manually set the bmp. Now i am unable to drawText, as i have placed this code within my paint() function. I would like, however, when i select this particular BitmapField , to drawText.

 

For the moment, setBitmap from another function is not a very good option as this will call the FieldManager's sublayout which i think may cause a stack problem. Is there any other way i can call drawText from?

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: how to call paint method from another program

What is the reason, again, for not drawing text from inside the paint()?  Why would you need to setBitmap() to draw the text in the first place?

 

Indeed, setBitmap() inside paint() will cause an infinite loop (I remember that post).  However, it should not be linked to drawing text in any way, shape or form.

 

Check some variable (member) inside your paint() method and do the draw you need depending on that value.  If you want your bitmapField to draw text under some conditions, change the value of that member and invalidate(), causing paint() to pick up the change.

 

Also, if your FieldManager's sublayout causes a problem, it has a problem.  Review that code and fix the bugs rather than masking them with all kinds of moving code around.

 

If you need further assistance, please post here the relevant code pieces (especially how you would draw the text back when it worked) and we'll figure out something.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Regular Contributor
Posts: 57
Registered: ‎07-27-2010
My Device: Bold 9700, 9000 and Storm 9520, 9500
My Carrier: SingTel

Re: how to call paint method from another program

hi there, thanks for your reply. i will try to debug first as mentioned. Starting from my sublayout. I'm pretty new to all this and my grasp on the whole dynamics is not very firm so it will take me some time. The main reason with my sublayout of my FieldManager,  is that i customized it quite a bit. so certain things, as you have mentioned is not working well. As i'm moving icons around the FM, i'm using insert, delete, etc as posted in my other posts, and i manually setfocus and even animate the icons. So now it's giving me a bit of a headache. Ha ha. Thanks again for all you guys' precious feedback and assistance. For this particular problem, i'll try to debug my FM's sublayout as well as navigationMovement first.... I'll post the codes if i am stuck at the crossroads once more... Thank you...