Here you can find the source of getStringBounds(Graphics2D g, Font font, String s)
public static Rectangle2D getStringBounds(Graphics2D g, Font font, String s)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.geom.*; public class Main { public static Rectangle2D getStringBounds(Graphics2D g, Font font, String s) {/*from w w w.ja v a2 s . c om*/ return g.getFontMetrics(font).getStringBounds(s, g); } }