|
-
May 6th, 2000, 05:57 AM
#1
How to catch the length of string in pixels
hello all,
i have got a doubt. Can any one help me
how to catch the length of a string in pixel.
For example i want to draw an image after printing
a string like this
"HEllo how are you" <Image>
"Hai fine how about you are you ok" <Image>
Can any one tell me a general approach for this
Thanx in advance
k_venkurao
-
May 6th, 2000, 07:57 AM
#2
Re: How to catch the length of string in pixels
You can use the FontMetrics class to get the length of a string in pixels. You can do this by the following:
FontMetrics metrics = aWindow.getFontMetrics(); // aWindow is a frame
int stringLength = metrics.stringLength( myString );
-------------------------------------------
weaver
icq# 64665116
Please rate this post.
http://weaver.x7.htmlplanet.com
-
May 7th, 2000, 11:44 PM
#3
Re: How to catch the length of string in pixels
Thank you very much for you reply. Can you tell the same for an applet. Because i have developed a chat server. I will to give an option for images
also.
Thankyou very much
k_venkurao
-
May 8th, 2000, 06:20 AM
#4
Re: How to catch the length of string in pixels
Ok, here's a version that should work with applets.
Graphics g = getGraphics();
FontMetrics fm = g.getFontMetrics();
int length = fm.stringLength(myString);
-------------------------------------------
weaver
icq# 64665116
Please rate this post.
http://weaver.x7.htmlplanet.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|