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... :(
# 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
# 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?
# 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]
# 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