PDA

Click to See Complete Forum and Search --> : Strings...


Virtual24
Apr 29th, 2003, 07:38 PM
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???

crptcblade
Apr 29th, 2003, 09:50 PM
//...
public void paint(Graphics g)
{
FontMetrics fm = g.getFontMetrics();

int w = fm.stringWidth("Some String!");
int h = fm.getHeight();
}
//...