| Author |
does java have a class to find string width?
|
Tina Long
Ranch Hand
Joined: Mar 04, 2005
Posts: 36
|
|
Does anyone have any suggestions on what I could do to figure out the width of a string? Ex: If I have two strings: "WHOOO HOOO" vs "ITTY BITTY" Both strings have the same number of letters however when I use a font that is not fixed width - then the second string takes up less room when typed. Is there anything out there that will help me find the width of the string? I need to take in account the font used and the string written - I've been looking at the Font class - but not finding what I need. Thoughts anyone?
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24040
|
|
|
FontMetrics.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Seb Mathe
Ranch Hand
Joined: Sep 28, 2005
Posts: 225
|
|
|
Look at the FontMetrics class.
|
Regards,<br />Seb<br /> <br />SCJP 1.4
|
 |
Tina Long
Ranch Hand
Joined: Mar 04, 2005
Posts: 36
|
|
Thanks - I believe that will work for me! YAY! How did you know that? Is it experience? I searched and read and I finally gave up and asked. Thanks for your quick response.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24040
|
|
|
Experience. FontMetrics is one of the original few hundred API classes, from way back in the Java 1.0 days when it was possible to know about all the classes in the API.
|
 |
 |
|
|
subject: does java have a class to find string width?
|
|
|