File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Issue with stringWidth() method of FontMetrics class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Issue with stringWidth() method of FontMetrics class" Watch "Issue with stringWidth() method of FontMetrics class" New topic
Author

Issue with stringWidth() method of FontMetrics class

Adwait Patankar
Greenhorn

Joined: Jan 30, 2006
Posts: 6
Hi,

We have an application supporting different languages.
In order to set the bounds of the tooltip, we require is to calculate the width based on the width of the string.

I'm doing the following :
----------------------------------
FontMetrics fm = getFontMetrics(this.cellFont);
int width = fm.stringWidth(tip);
----------------------------------

Issue is : length of the string and Font remaining same, if any accented character appears in the string, width returned is same. But while actual display of accented characters it is taking more space.
Hence my strings are getting cut when shown in the tooltip.

Is there any known issue for stringWidth() method of FontMetrics?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with stringWidth() method of FontMetrics class