File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes How to get the size of a string in pixels? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How to get the size of a string in pixels?" Watch "How to get the size of a string in pixels?" New topic
Author

How to get the size of a string in pixels?

monojit choudhury
Greenhorn

Joined: Nov 20, 2000
Posts: 23
Hi
Is there any way by which i can get the size
of a string in pixels? I mean depending on the
font size and style,i get the length of the string
in pixels.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12678
    
    5
Sounds like you are looking for the FontMetrics class in the java.awt package. Thats the class which can tell you such things as the display size of a string in pixels and the other data you need to exactly position text.
Bill


Java Resources at www.wbrogden.com
 
 
subject: How to get the size of a string in pixels?
 
Similar Threads
getting problem in creating an image from int array
Convert JFrame to image
Crop an image in Java
planning to buy MacBook
Size of String in Pixels from JTextField