I need to find the bounds of a String in order to center it in a rectangle when painted with a instance of Graphics. HOW DO I DO THIS???
Printable View
I need to find the bounds of a String in order to center it in a rectangle when painted with a instance of Graphics. HOW DO I DO THIS???
Code://...
public void paint(Graphics g)
{
FontMetrics fm = g.getFontMetrics();
int w = fm.stringWidth("Some String!");
int h = fm.getHeight();
}
//...