I had to figure this out recently to center some text. Here is what worked for me -
Font barFont = new Font("Serif", Font.BOLD, FONT_SIZE);
FontRenderContext frc = new FontRenderContext(null, true, false);
TextLayout tLayout = new TextLayout("My text here", barFont, frc);
Rectangle2D textRect = tLayout.getBounds();
int textXStart = (getWidth() - (int)textRect.getWidth()) / 2;
int textYStart = (BAR_HEIGHT + (int)textRect.getHeight()) / 2;
tLayout.draw(g, textXStart, textYStart);
This would center my text inside a progress bar I had at the bottom of my swing component.
AFAIK, the only difference between doing it this way and using the FontMetrics is that this will support doing things such as rotating your text and such. You would change the AffineTransform passed into the FontRenderContext.