I forgot to add that this is for setting the bounds width within a Java
application (painted text, not a JLabel/Label component). Not exactly sure
what circumstance you are operating under.
Michael wrote:
> I use the following as a utility class:
>
>
>
> import java.awt.Component;
> import java.awt.Font;
> import java.awt.FontMetrics;
>
> public final class TextWidthChecker extends Component
> {
> private Font f = null;
>
> public TextWidthChecker(String fnt, int size)
> {
> f = new Font(fnt, Font.PLAIN, size);
> }
>
> public int getTextWidth(String s)
> {
> int width = -1;
>
> FontMetrics fm = getFontMetrics(f);
> width = fm.stringWidth(s);
>
> return width;
> }
> }
>
> Henry Lu wrote:
>> How do we determine the length of string with no Frame window, no
>> Applet? (we know the font and size)
>>
>> -Henry
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]