BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 04-13-2010, 09:44 AM   #1 (permalink)
Knows Where the Search Button Is
Join Date: Mar 2010
Model: 7100T
Carrier: job
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default word wrap

Please Login to Remove!

i implement list field but i have long text field how to make word wrap format in paint methode .
my code here

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();


please help code via.
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

APPLE 820-0522-A 630-0895-B LITE VRAM 128K X 8 BOARD
APPLE 820-0522-A 630-0895-B LITE VRAM 128K X 8 BOARD   picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.