This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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
 
It's not a secret anymore!