Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2004

Tip: Looking for answers? Try searching our database.

AttributedString width...

Thread view: 
Andreas Beresko - 04 Aug 2004 03:22 GMT
Hi,

I'm drawing text in Graphics2D by setting a font with AttributedString (see
code below)

AttributedString as = new AttributedString(text);
as.addAttribute(TextAttribute.FAMILY, textElement.getFontName());
as.addAttribute(TextAttribute.SIZE,new Float(textElement.getFontSize()));´

My Question: is there any possibilty to get the width of the text before
it's drawing?
I tried the "normal" way by using a new Font object, but i was'nt able to
underline text, so i had to take
the AttributedString solution.

best regards Andreas
Hal Rosser - 04 Aug 2004 05:47 GMT
look at the fontmetrics class

> Hi,
>
[quoted text clipped - 12 lines]
>
> best regards Andreas
Christian Kaufhold - 05 Aug 2004 18:01 GMT
> I'm drawing text in Graphics2D by setting a font with AttributedString (see
> code below)
[quoted text clipped - 8 lines]
> underline text, so i had to take
> the AttributedString solution.

java.awt.font.TextMeasurer
java.awt.font.TextLayout

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.