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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
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.