Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How many pixels does a string occupy??

843807Feb 13 2003 — edited Feb 14 2003
I'm making a credit script and have a little problem with centering the
strings. If one string is eg. 12 characters long how many pixels will it occupy on screen? This depends on which letters the string contains. So the question is, HOW can i calculate the space (in pixels) needed to print any given string. (The size of the letters is constant!)

Is it any other way to center a string on screen? I have a tendency to think a little complicated.. :)

Any help is welcome. Code or just ideas is great!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2003
Added on Feb 13 2003
3 comments
339 views