Implementing methods of The FontMetrics class
i am trying to draw a string in the exact center of a JPanel..........
for the x(horizontal position) i am using:
getWidth() / 2 - Graphics.getFontMetrics().stringWidth( string ) / 2
which is working fine.....
what do i need to use for the y(vertical position)??
the entire code for the drawing (so far) is:
Graphics.drawString( string, getWidth() / 2 - Graphics.getFontMetrics().stringWidth( string ) / 2, getHeight() / 2 - Graphics.getFontMetrics().getHeight() / 2 );
but the string is being displayed too high.......
how do i get the height of the string currentley being drawn??
What is that, something to eat?
"All things being equal, the simplest solution tends to be the best."