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

BlackBerry Development Advisor
Posts: 15,874
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

RichTextField width

Quote from the previous forum:

RichTextField width
Posted: Jul 17, 2008 4:07 PM
I am using a horizontal manager that contains a RichTextField followed by a button. In order to lay them correctly I need to get the width of the RichTextField.
Even though the text is not filling the whole line, It is returning the width as the whole screen width. The preferredWidth is returning a very small number.
So what to do to get the actual width that the field is taking? By the way the text in the field is a multiline text.



So are you trying to get the width of the text alone?  The Font.getAdvance method accepts a String and returns the lenght of the text in pixels using the current font.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.