public static int horizontalCentering (Font f, String s)

I wish there were such a method!
I want the method to return the offset i need for displaying the string centered.

Is there any way to find out the pixel width or height being used by a string at a given font?

I am working on horizontalcentering and verticalcentering methods for my strings but since they are font dependant it gets tricky!

java.awt.FontMetrics

One of my favorite utilities for graphical text processing and alignment is TextLayout: http://java.sun.com/javase/6/docs/api/java/awt/font/TextLayout.html