Drawing a String using Graphics Object
When I am printing a long String using the following method
String currentMessage // The size of the String is large
g.drawString(currentMessage, x, y, Graphics.BOTTOM | Graphics.HCENTER);
only the middle of the String is shown on the sreen.The first and last parts are stripped off because of the size of the screen.
Anyone knows how to specify the size of the font, or how to force the string to continue on a new line if its size is bigger than the width of the screen?
Cheers
[517 byte] By [
MIKE9009a] at [2007-11-27 6:11:12]

# 1
There is not native support for line wrapping in drawString().
You can change the font by using g.setFont(),
Create your on font, and specify the font size as small.
The Font class includes a method to determine the length of a string. You can use this method to check the length of the String if the string is longer than the screen width, you can break the String into parts (substrings) and draw each of the parts.
Alternatively, you can use this line wrapping class http://hostj2me.com/appdetails.html?id=6