Problem with draw the string into rectangle

Hi to all,

I have a problem with my j2me application.

I have a rectangle and into it i would like draw the string, but if the width string is bigger than width rectangle i would truncate the string.

I don't know how i can do this.....

Any idea?

Please help me... :(

[303 byte] By [fighter79@inwind.ita] at [2007-11-27 4:17:55]
# 1

> Hi to all,

> I have a problem with my j2me application.

> I have a rectangle and into it i would like draw the

> string, but if the width string is bigger than width

> rectangle i would truncate the string.

> I don't know how i can do this.....

> Any idea?

>

> Please help me... :(

Three steps to do this,

1. Take a look at the String class API Doc,

2. Take a look at the Font class API Doc, and finally

3. Use your brain and write the reqd. codes.

and voila...

Regds,

SD

find_suvro@SDNa at 2007-7-12 9:24:36 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

So...

The problem isn't drawing the string into rectangle, but it is drawing the characters of the string that enter in the rectangle.

i.e. :

if the width rectangle is 30 and the string is longer than width rectangle, i must truncate some characters of the string. But, having the String class don't have a method to get the string width in pixel, i don't know at which pixel to truncate the string so that this enter into the rectangle.

Do you understand?

fighter79@inwind.ita at 2007-7-12 9:24:36 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
it's in the Font class...check [url= http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Font.html#substringWidth(java.lang.String,%20int,%20int)]this[/url] and [url= http://developers.sun.com/techtopics/mobility/midp/articles/termemulator3/]that[/url]
suparenoa at 2007-7-12 9:24:36 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

> So...

> The problem isn't drawing the string into rectangle,

> but it is drawing the characters of the string

> that enter in the rectangle.

>

> i.e. :

>

> if the width rectangle is 30 and the string is longer

> than width rectangle, i must truncate some characters

> of the string. But, having the String class don't

> have a method to get the string width in pixel, i

> don't know at which pixel to truncate the string so

> that this enter into the rectangle.

>

> Do you understand?

hmm, I feel I failed to make u understood. well I mentioned the String class 'cuz u need to truncate the String to the reqd length.

and the Font class 'cuz there u will find the method to get the length of the String in pixels.

and lastly, there is no such method that will truncate the String to ur reqd pixels, so u need to write ur own method for that.

I think this time I am able to make u understand.

Regds,

SD

find_suvro@SDNa at 2007-7-12 9:24:36 > top of Java-index,Java Mobility Forums,Java ME Technologies...