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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer
Accepted Solution

how to repaint a text in a labelfield

I have a labelfield with text.I want that when i click a button,the labelfield text should change.I have tried with labelfield.settext method,but its not working,plz help

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to repaint a text in a labelfield

<LabelField>.setText method does change the text.  Debug the statement, I suspect it is throwing an Exception, probably because you are not invoking it on the Event Thread.  . 

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to repaint a text in a labelfield

but how to delete the old text and put a a new text

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to repaint a text in a labelfield

if your LabelField is called lab and is on the screen, then

 

lab.setText("New Text").

 

will update the display with "New Text", assuming you run this on the Event Thread. 

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to repaint a text in a labelfield

yes true,but if i use draw text in paint method and than use settext in the onnavigation click of button field,text is overlapping on the old text,how to delete the old text

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to repaint a text in a labelfield

or else like drawtext is there any way to set postion in settext

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to repaint a text in a labelfield

Ah - I thought you were using a standard LabelField.  Might have been useful to mention that at the start.

 

If you really have to use drawText, then you should clear the area first.  There are a variety of ways you can do that, but probably the easiest is to just call paintBackground in your paint() method.

 

Otherwise you can set the color and use fillRect.  Review the Graphics API for more on these methods. 

 

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to repaint a text in a labelfield

yes Peter i too hate using DrawText,but i dont have any option.Actually i need to position the text inside labelfield depending on alignment attribute value i am getting from an XMl,so suppose its CENTER,i am setting it at center in drawtext,anyways i will give ur solution a try and get back to u

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to repaint a text in a labelfield

I am actually using g.clear(); coz super.paintbackground() doesnt clear the text

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to repaint a text in a labelfield

but its going complete white,my backgroudn image is not vsisble once i do g.clear()