Line Wrap Example
astrient • Jan 12, 2006 • 813

The LineEnumeration wraps text on a canvas.

Platform

J2ME

Usage Example

Within the paint method:

String longText = ...;
Font myFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL);
LineEnumeration e = new LineEnumeration(myFont,,getWidth());
e.writeTo(g,10,10,myFont);


Alternative:

LineEnumeration e = new LineEnumeration(myFont,myText,lineWidth);
while ( e.hasMoreElements() )
{
g.drawString(e.nextElement().toString(), startX,startY, Graphics.TOP | Graphics.LEFT);
startY += myFont.getHeight();
}


Device Compatibility

Should work on all Midp 2.0 devices.