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
Posts: 44
Registered: ‎07-15-2010
My Device: Not Specified
Accepted Solution

Physical size of a String?

Is there some way to find the actual size of a string? 

 

Using java.awt.FontMetrics you can do something like this:-

FontMetrics fm = someComponent.getFontMetrics(someFont);
int width = fm.stringWidth(someString);

 

Is there something similar for Blackberry?

 

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

Re: Physical size of a String?

you can use font getAdvance

----------------------------------------------------------
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
Highlighted
Contributor
Posts: 44
Registered: ‎07-15-2010
My Device: Not Specified

Re: Physical size of a String?

Thanks Simon, that was painless.