Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Contributor
Posts: 8
Registered: ‎02-25-2010
My Device: jde
My Carrier: developer

Word Wrap Field Issue

i create list fielde ,it have fore vectors one bitmap,three is string but string is some time come on very long legenth how to scroll the text on next line (same as wrap word field) please helpme .


my code:


import java.util.Vector;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
class ListCallBack implements ListFieldCallback
private Vector listElements = new Vector();
private Vector listElements1 = new Vector();
private Vector listElements2 = new Vector();
private Vector listImg = new Vector();
int width,height;

public void drawListRow(ListField list, Graphics g, int index, int y, int w)
String Name = (String)listElements.elementAt(index);
String dateofbirth = (String)listElements1.elementAt(index);
String status = (String)listElements2.elementAt(index);

Bitmap image=(Bitmap)listImg.elementAt(index);

int imgwidsize=image.getWidth();
int textwid=(imgwidsize)+10;
int fonthight=g.getFont().getHeight();
int z=y+5;
int fhight=z+fonthight;
int totalwidth=width-imgwidsize;
// System.out.println("width="+totalwidth+"textwid"+N ame.length()) ;

g.drawBitmap(0,z,image.getWidth(),image.getHeight( ),image,0,0);
g.drawText("Name : "+Name,textwid,z,DrawStyle.LEADING | DrawStyle.ELLIPSIS, w-textwid);
g.drawText("Dob : "+dateofbirth,textwid,fhight,DrawStyle.LEADING | DrawStyle.ELLIPSIS, w-textwid);
g.drawText("Status : "+status,textwid,fonthight+fhight,DrawStyle.LEADIN G | DrawStyle.ELLIPSIS, w-textwid);
public Object get(ListField list, int index)
return listImg.elementAt(index);

public int getPreferredWidth(ListField list)
return Display.getWidth();

public void insert(String toInsert ,int index)

public void insert1(String toInsert ,int index)
public void insert2(String toInsert ,int index)

public void insertimg(Bitmap toInsertmap ,int index)

public void erase()

public int indexOfList(ListField listField, String prefix, int start) {
return listImg.indexOf(listField);

public int size() {
return listImg.size();





Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Word Wrap Field Issue

According to the API,  ListField does not support different size rows.  So you can't make one entry bigger than any of the other ones.  You can make then all multiple line, but then, without a great deal of complicated work, it is best to do the word wrap yourself.