Re: size of a string in pixel ?

> the thing is that in order to preserve the layout, I'd like to set the
> component's size to its maximum
> ( eg. if the JtextField contains a Date, i'll set it to the size
> necessary to hold "wednesday, december 25th" )
> in order to compute this size, I need to translate number of characters
> to pixels. ( taking into account the fonts )
> How can I do this ?
see FontMetrics#stringWidth(String s);

Andrey Kuznetsov Unified I/O for Java Java image reader Java GUI components and utilities