Hi guys, i got another little "problem".
I used the font "Monospaced" so that the letters are all the same size, but how do i get the width of a letter so i can center a text with every length in my screen? Are there any Ideas to this?


1 | g = myGreenfootImage.getAwtImage().createGraphics(); |
1 2 3 | FontMetrics fm = getFontMetrics( new Font( "MONOSPACED" ,Font.BOLD, 50 )); getBackground().drawString( "Highscore Top 5" ,getBackground().getWidth()/ 2 -fm.StringWidth( "Highscore Top 5" )/ 2 , 50 ); |