title: How to Perfectly center a String in a Center Jpanel
body: <p>I am drawing 2 Strings which the one include my Name, Middle-name, Surname and the other my Country i am creating them  in a paint Component which is located in a Center panel, however, I have tried many different ways and calculations to center that String but no one of them is working correctly with accuracy is their an accurate way ?  this is an example of calculations that i have tried so far     </p>
  
  <pre><code>posX=((getWidth()-fm.stringWidth(phrase))/2);
  posY= ((getHeight()-fm.getHeight())/2);  
  </code></pre>