getting pixel-width of a java.awt.Font String

hello, is there a possibility to find out how long a String is when i draw it onto a BufferedImage using

graphics2d.drawString(String, x,y);

i need that so that i can implement my own textfield with linebreaks, etc.

thanks!

graphics2d.getFont(myFont);
graphics2d.getFontMetrics().stringWidth(myString)

And don’t forget TextLayout and LineBreakMeasurer !

Lilian :slight_smile:

thanks guys!