[java] Centering text
I have a String that I want to place in a box in my frame. Now I can manually adjust it until it looks right but then when I put a different sized string of text it''s not centered as it should be. Is there a function that can center text on an x axis? I''ve looked it setHorizontalText or something but I couldn''t get it to work right.
If you are using awt you can get a FontMetrics object from the Graphics (Graphics.getFontMetrics()) object and use the FontMetrics.stringWidth(String) to get the width of the string.
Hope that helps....
:-)
Hope that helps....
:-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement