Welcome!

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

Reply
Contributor
Posts: 11
Registered: ‎01-17-2011
My Device: N9000
My Carrier: Vodafone

TreeField paint problem: missing last node text

Hi,

 
I have the weirdest issue probably with the simplest fix - i use a treefield taking up most of a screen in my app.  App is build with JRE 4.5 (for backward compat reasons)


The Treefield's nodes consist of countries, soem countries have child nodes of cities (2 tiers). In the case of the USA i have States and in some of them specific Cities (3 tiers).


My issue: X nodes text values at the bottom of my treefield are not painted to my UI (but are selectable) where X is the amount of 3rd tier nodes i have.


If i remove the US 3rd tier nodes my last nodes get painted correctly and the user can see their text values.


(What do I mean by no text but selectable?: the user sees a number of blank lines that when they move their cursor down to it it looks like nothing is selected/focused but if they select save the app saves corrrectly)

 
 

Anyone have any idea what is going on here - see below for my code ?????????

 


TreeCallback myCallback = new TreeCallback();final TreeField myTree = new TreeField(myCallback, Field.FOCUSABLE);/*


 /*within my main UI class/*

...

this.removeAllMenuItems();

TreeCallback myCallback = new TreeCallback();

final TreeField myTree = new TreeField(myCallback, Field.FOCUSABLE);

int nodeTestVietnam = myTree.addChildNode(0, "Vietnam");
int nodeUnitedKingdom = myTree.addChildNode(0, "United Kingdom");
int nodeUkraine = myTree.addChildNode(0, "Ukraine");
int nodeTurkey = myTree.addChildNode(0, "Turkey");
int nodeTaiwan = myTree.addChildNode(0, "Taiwan");
int nodeSweden = myTree.addChildNode(0, "Sweden");
int nodeSingapore = myTree.addChildNode(0, "Singapore");

int nodeUSA = myTree.addChildNode(0, "USA" );  
int nodeUSA_Washington = myTree.addChildNode(nodeUSA, "Washington" );
int nodeUSA_Utah = myTree.addChildNode(nodeUSA, "Utah" );
int nodeUSA_Texas = myTree.addChildNode(nodeUSA, "Texas" );
int nodeUSA_SouthCarolina = myTree.addChildNode(nodeUSA, "South Carolina" );
int nodeUSA_Oregon = myTree.addChildNode(nodeUSA, "Oregon" );
int nodeUSA_JonesFarm = myTree.addChildNode(nodeUSA_Oregon, "Jones Farm" );
int nodeUSA_HawthorneFarm = myTree.addChildNode(nodeUSA_Oregon, "Hawthorne Farm" );
int nodeUSA_NewMexico = myTree.addChildNode(nodeUSA, "New Mexico" );
int nodeUSA_Massachusetts = myTree.addChildNode(nodeUSA, "Massachusetts" );
int nodeUSA_Colorado = myTree.addChildNode(nodeUSA, "Colorado");
int nodeUSA_California = myTree.addChildNode(nodeUSA, "California" );
int nodeUSA_SantaClara = myTree.addChildNode(nodeUSA_California, "Santa Clara" );
int nodeUSA_Sacramento = myTree.addChildNode(nodeUSA_California, "Sacramento");
int nodeUSA_Irvine = myTree.addChildNode(nodeUSA_California, "Irvine" );
int nodeUSA_Folsom = myTree.addChildNode(nodeUSA_California, "Folsom");
int nodeUSA_Arizona = myTree.addChildNode(nodeUSA, "Arizona");
int nodeUSA_Ocotillo = myTree.addChildNode(nodeUSA_Arizona, "Ocotillo");
int nodeUSA_Chandler = myTree.addChildNode(nodeUSA_Arizona, "Chandler");


 for(int i = 1; i<=myTree.getNodeCount(); i++)

{

 myTree.setExpanded(i, false);

}


_fieldManagerTop.add(CBField);

_fieldManagerMiddle.add(myTree);

}
private class TreeCallback implements TreeFieldCallback
{
 public void drawTreeItem(TreeField tree, Graphics g, int node, int y, int width, int indent)
 {
  String text = (String)tree.getCookie(node);
  double inc = Display.getWidth()*(0.04);
  int incInt = (int)inc;
  int indentTemp = 0;
  if(tree.getParent(node)!=0)
  {
   indent =indent+incInt;
   int node1 = tree.getParent(node);
   if(tree.getParent(node1) !=0)
   {
    indent =indent+incInt;

   }

 }

 g.drawText(text, indent, y);

}
}

Developer
Posts: 516
Registered: ‎07-23-2010
My Device: 9900

Re: TreeField paint problem: missing last node text

Should your loop start from i = 0?

Contributor
Posts: 11
Registered: ‎01-17-2011
My Device: N9000
My Carrier: Vodafone

Re: TreeField paint problem: missing last node text

Hi BB_Dude,

I have to start from 1 as there is no 0 node. App throws nul exception so 1 up to and including last node.