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]