title: Updating Rendered Tree Cells
body: <p>Here is my application.</p>
  
  <p><img src="https://i.stack.imgur.com/ZtDf7.png" alt="enter image description here"></p>
  
  <p>What I want to do is make it so that when the user's details are updated, so does it's node in the JTree. Is this possible; even though the JTree and it's rendered cells have already been created?</p>
  
  <p>I need an example of updating a rendered cell even after it has already been created.</p>
  
  <p>Here is my View code:</p>
  
  <pre><code>void createTree() {
  
      rootNode = new DefaultMutableTreeNode("users");
  
      for (User user : listOfUsers) {
  
          String id = user.getId();
          File file = new File(id);
          DefaultMutableTreeNode node = new DefaultMutableTreeNode(file);
          rootNode.add(node);
      }
  
      treeModel = new DefaultTreeModel(rootNode);
      tree = new JTree(rootNode);
  }
  
  void addTreeModelListener(TreeModelListener a) {
  
      treeModel.addTreeModelListener(a);
  }
  
  void repaintTree() {
  
      treeModel.reload();
      tree.revalidate();
      tree.repaint();
  }
  </code></pre>
  
  <p>And here is my Controller code:</p>
  
  <pre><code>view.addTreeModelListener(new MyTreeModelListener());
  
  class MyTreeModelListener implements TreeModelListener {
      public void treeNodesChanged(TreeModelEvent e) {
  
          DefaultMutableTreeNode node;
          node = (DefaultMutableTreeNode)(e.getTreePath().getLastPathComponent());
  
          int index = e.getChildIndices()[0];
          node = (DefaultMutableTreeNode)(node.getChildAt(index));
  
          System.out.println("The user has finished editing the node.");
          System.out.println("New value: " + node.getUserObject());       
      }
  
      public void treeNodesInserted(TreeModelEvent e) {}
      public void treeNodesRemoved(TreeModelEvent e) {}
      public void treeStructureChanged(TreeModelEvent e) {}
  }
  </code></pre>
  
  <p>The idea is after the changes to the objects have been made, I call the repaintTree() method. After looking over the code now, I think the problem lies in the fact that I'm changing the object details and not the node details, but that's just a hunch.</p>
  
  <p>Please reply soon, many thanks.</p>