title: java JTree not updating
body: <p>I am having some issues with JTree. When I create my DefaultTreeModel within the same class, the JFrame updated fine. However, I want to call the update method from another class and when I do the JTree remains blank. The JTree is in the class GUI and stored like so in another class called store.</p>
  
  <pre><code>public static GUI UI = new GUI();
  </code></pre>
  
  <p>...</p>
  
  <pre><code>UI.init();
  UI.buildJTree(xml);
  </code></pre>
  
  <p>However, this does nothing. I however inside the class GUI I call:</p>
  
  <pre><code>buildJTree(xml);
  </code></pre>
  
  <p>Everything works fine. Does anyone have any ideas as to why there might be a problem?</p>
  
  <p>Build Tree method is as follows:</p>
  
  <pre><code>public void buildTree(String xml) {
      try {
          Console.output("Building tree");
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder db = dbf.newDocumentBuilder();
          InputSource is = new InputSource();
          is.setCharacterStream(new StringReader(XML.wrap(xml.trim())));
          Document doc = db.parse(is);
          NodeList xml_packet = doc.getElementsByTagName("packet");
          NodeList channels = xml_packet.item(0).getChildNodes().item(0).getChildNodes();
  
          Element start = (Element) xml_packet.item(0).getFirstChild();
          this.status_txt.setText(start.getAttribute("connected") + ", connected.");
          MutableTreeNode root = new DefaultMutableTreeNode(start.getAttribute("server"));
  
          for (int n = 0; n &lt; channels.getLength(); n++) {
              Element fstElmnt = (Element) channels.item(n);
              Console.output("CHANNEL::" + fstElmnt.getAttribute("name"));
              DefaultMutableTreeNode userss = new DefaultMutableTreeNode(fstElmnt.getAttribute("name"));
              root.insert(userss, n);
  
              NodeList users = channels.item(n).getFirstChild().getChildNodes();
  
              for (int usr = 0; usr &lt; users.getLength(); usr++) {
                  userss.insert(new DefaultMutableTreeNode(users.item(usr).getFirstChild().getNodeValue()), usr);
              }
          }
  
  
          model = new DefaultTreeModel(root);
  
          this.trees.setModel(model);
  
          for (int t = 0; t &lt; this.trees.getRowCount(); t++) {
              this.trees.expandRow(t);
          }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>Many Thanks in advance.</p>