I have some questions regarding a treemodel in Java.
For the last 13 weeks in class we've been developing a contact manager. This contact manager has various components: a contact can either be a business contact or personal contact, and each has their own set of events. They also have addresses, social networks, and phone numbers.
Last assignment we had to read information from an outside txt file and implement it in our project. That went fine. Now he wants us to build a treeModel out of the information from said text, but I'm having a really hard time understanding how this tree model works.
For example, root, parent, children, nodes are all words I'm trying to define but having a really hard time. In this case would my root be my contact manager, my parent by a contact and children be like address and stuff? If someone could help me understand it it would really help.
Here's a excerpt from the assignment if it helps you understand my question more:
Create class ContactManagerFrame that extends JFrame. Its constructor will take as argument a ContactManager object (retrieved from the serialized file saved on disk).
Create and layout the required graphical components. (Hint: use a JPanel to group the components of the filtering feature, add the JTree to a JScrollPane, use BorderLayout when adding the components)
Create method createNodes() that takes as arguments a DefaultMutableTreeNode corresponding to the root of the tree (i.e., “Contacts” node) and a String corresponding to the filter specified by the user. This method should create nodes for the contacts and the objects referenced by each contact and organize them in a tree structure, as shown in Figure 1. You should avoid the creation of empty parent nodes (e.g., if a contact does not have any addresses, you should not add a parent node “Addresses” for this particular contact). If the specified filter is an empty string, createNodes() will include all contacts stored in the ContactManager object. In any other case, createNodes() will include the contacts returned by method searchContacts() in ContactManager.
Create a DefaultTreeModel object from the root node. Use the DefaultTreeModel to initialize the JTree component.'
I'm not asking any of you to solve it for me or anything. I just really want to understand it. Thank you very much!