JTree and JNode can be used to create and process simple tree structures. Let's see how this works for JNode with a simple example.
We want represent the family structure of the Smiths. Granny Barbara has two daughters. Stefanie and Aunti Sue. Stefanie has two children, Peter and Stewie. Auntie Sue doesn't have children.
Let's take a look how we can represent this familiy in an object tree.
$barbara=newJNode();$stefanie=newJNode();$sue=newJNode();$peter=newJNode();$stewie=newJNode();//Granny Barbara has two children, stefanie, and sue$barbara->addChild($stefanie);$barbara->addChild($sue);/* * Sometimes we want declare parent-child relationships the other way around. * We can also do that */$peter->setParent($stefanie);$stewie->setParent($stefanie);
JTree and JNode can be used to create and process simple tree structures. Let's see how this works for JNode with a simple example.
We want represent the family structure of the Smiths. Granny Barbara has two daughters. Stefanie and Aunti Sue. Stefanie has two children, Peter and Stewie. Auntie Sue doesn't have children.
Let's take a look how we can represent this familiy in an object tree.