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
Contributor
anshulmittal_nsit
Posts: 15
Registered: ‎06-11-2010
My Device: NA
Accepted Solution

issue in overriding paint of richtextfield

I have overriden richtextfield and then overridden the paint method.

Inside the paint method i want to draw a string.

My aim is that the overridden class object invalidates itself from outside and then because of invalidation paint method gets called.

Inside the paint method i have a string already present as a variable(which might have been obtained in any way).Now i want to draw this string.

If i use suprer.settext(string) inside the paint method then it creates an infinite loop.I believe that this is because settext() results in calling of invalidate which again calls paint which leads to again calling settext and hence the lopp.

Therefore i want to know how to draw the given string without there being an infinite loop.

 

Please use plain text.
Developer
Hithredin
Posts: 404
Registered: ‎06-03-2010
My Device: Z10 Red

Re: issue in overriding paint of richtextfield

 

Try just to do that :

 

if( ! getText().equals(string) ) {

   super.setText(string)

}

Please use plain text.
Contributor
anshulmittal_nsit
Posts: 15
Registered: ‎06-11-2010
My Device: NA

Re: issue in overriding paint of richtextfield

thak u.Nice solution

Please use plain text.
Contributor
doc_taco
Posts: 13
Registered: ‎06-18-2010
My Device: na

Re: issue in overriding paint of richtextfield

Those string compares can be expensive.  Wouldn't you rather use a flag to indicate the text has been set?  

Please use plain text.