If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
New Developer
joschika77
Posts: 24
Registered: ‎09-12-2008
My Device: Not Specified

TreeField & FieldChangeListener

Hello, I have a problem with the ChangeListener there he not reacted with click on childNode. What do I make wrong?

 

 

TreeField aTreeField = new TreeField(aTreeCallback,Field.FOCUSABLE); aTreeField.setChangeListener(new ETreeChangeListener()); //aTreeField.setFocusListener(new ETreeFocusListener()); String aMainNode = new String("Main"); String aT1Node = new String("Test 1"); String aT2Node = new String("Test 2"); int node1 = aTreeField.addChildNode(0, aMainNode); int node2 = aTreeField.addChildNode(node1, aT1Node ); int node3 = aTreeField.addChildNode(node1, aT2Node); aTreeField.setExpanded(node1,false); //Inner class class ETreeChangeListener implements FieldChangeListener { public void fieldChanged(Field field, int context) { System.out.println("Hello"); } }

 

 

 

Please use plain text.
New Developer
joschika77
Posts: 24
Registered: ‎09-12-2008
My Device: Not Specified

Re: TreeField & FieldChangeListener

Can nobody help me? Best regards
Please use plain text.
Developer
KarlH
Posts: 29
Registered: ‎09-12-2008
My Device: Curve 8330

Re: TreeField & FieldChangeListener

When I've used the FieldChangeListener I've used it for noticing changes in the field on the screen, not changes made from the program itself.  It works well for listening for changes made by the user on the screen.  Perhaps it's not meant to listen for any changes in the class, but just input changes.
Please use plain text.
New Developer
joschika77
Posts: 24
Registered: ‎09-12-2008
My Device: Not Specified

Re: TreeField & FieldChangeListener

ohhhh.... its not good. Then I have to intercept only the FocusListener for the choice around events.

I do not understand the sense of the Tree then so properly. hmmm...nevertheless, thank you

Please use plain text.
Developer
stevewarsa
Posts: 43
Registered: ‎12-02-2008
My Device: Curve 8330

Re: TreeField & FieldChangeListener

Did you ever figure out how to listen for changes on a tree field?
Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: TreeField & FieldChangeListener

You can override the navigationClick method of TreeField to detect when a user has clicked on it.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
EpicDraws
Posts: 109
Registered: ‎02-09-2009
My Device: Not Specified

Re: TreeField & FieldChangeListener

Can you post some more details? I cannot figure out how to perform an activity based on the cookie in the selected node. Can you help?
Please use plain text.
Developer
nathanpc
Posts: 134
Registered: ‎05-19-2012
My Device: Torch 9800, PlayBook 64GB, Dev Alpha
My Carrier: VIVO Brazil

Re: TreeField & FieldChangeListener

Any news about this? I would like to hear more details from @MSohm. :smileyhappy:

Best Regards.
If I helped you please click the "Like" button to support my work.
My apps: CherryNotes - Bookmarked - Requests
Social Me: about.me - Twitter
Please use plain text.
Developer
pankajace12
Posts: 192
Registered: ‎04-30-2011
My Device: Software
My Carrier: Airtel

Re: TreeField & FieldChangeListener

Hi joschika

 

Try this code:

 

class TreefieldScreen extends MainScreen
{
    public TreefieldScreen()
    {             
        setTitle("Tree Field Demo");
        
        String fieldOne =  new String("Pawan Main 1");
        String fieldThree =  new String("Pawan - sub -folder 1");
        String fieldFour =  new String("Pawan - sub -folder 2");
        
        TreeCallback myCallback = new TreeCallback();
        TreeField myTree = new TreeField(myCallback, Field.FOCUSABLE);
        
        int node1 = myTree.addChildNode(0, fieldOne);
        int node3 = myTree.addChildNode(node1, fieldThree);
        int node4 = myTree.addChildNode(node3, fieldFour);
       
        myTree.setExpanded(node4, false);
        
        add(myTree);

    }
    
    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); 
            g.drawText(text, indent, y);
        }
    }
}

 

Thanks
Pawan 

Please use plain text.