Thursday, February 4, 2010

Nested Table Component for Blackberry

Based on our last Simple Table component, I have put together a Nested Table as well. The main features are:

-Each row can be rendered like an irregular table
-Each row is backed by an object
-Possibility to add a popup to row click

These classes demonstrate how to use the component:

You would need the following classes to make this work:

Possible improvements:
-implementing varying row heights
-implement table header, table footer and column header

Wednesday, February 3, 2010

A Simple Table Component for Blackberry

Just worked on making a J2ME based prototype for a Blackberry (JDE 4.7+). The documentation, the website and the API are horrible, to say the least. We are using the Eclipse Plugin for development. One of the prime difficulties we faced was the absence of a well-defined table component. "ListField" is horribly designed and the example that is given in their documentation does needs serious improvement. Moreover, to make a flexible component that renders a list of messages (like the SMS message list) with each composite row selectable as a whole, no example could really help. So, I have made two components that you can improve upon and use as you please.

The first one, that is given in this post, is a simple table. It takes a 2-D array of fields and converts it into a visual table. It simply improves upon ListField. You would need the following three classes:

Then in you code, use a similar code snippet to make and add a table (here we use it to create the title of the screen):

Field[][] titleContent = new Field[1][];
titleContent[0] = new Field[3];
titleContent[0][0] = new LabelField("S.No.",
titleContent[0][1] = new LabelField("Message",
titleContent[0][2] = new LabelField("Time",
int[] widthPercent = {10,63,27};
int[] paddings = { 5, 0, 0 };
setTitle(new BSimpleTable(titleContent,
widthPercent, paddings,

If you don't want to sign the application, hard code the total screen width instead of using Display.getWidth()

Also, see: Version Specific Developmnet Guides (3.6 to 5.0 beta)