title: JUNG: placing tree nodes in order
body: <p>When adding nodes to my <code>DelegateTree</code>, they don't appear visually in the order I added them.
  I've been looking for a solution, but haven't found anything yet.
  Is there anyone who might know how to change this?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT</strong>: My code</p>
  
  <pre><code>/**
   * Generate a visualization of the decision tree.
   * 
   * @param tree
   *            The decision tree
   * @return A component to be placed inside a JPanel
   */
  public static GraphZoomScrollPane generateTree(Tree tree,
          GraphicalUserInterface gui) {
  
      /* Create a new tree */
      DelegateTree&lt;Node, Edge&gt; graphTree = new DelegateTree&lt;Node, Edge&gt;();
  
      /* Add all nodes and vertices to the tree */
      graphTree.addVertex(tree.getRoot());
      addChildren(tree.getRoot(), graphTree);
  
      /* Create the visualization */
      DynamicTreeLayout&lt;Node, Edge&gt; treeLayout = new DynamicTreeLayout&lt;Node, Edge&gt;(graphTree, 100, 100);
      VisualizationViewer&lt;Node, Edge&gt; vv = new VisualizationViewer&lt;Node, Edge&gt;(
              treeLayout);
      vv.setDoubleBuffered(true);
      vv.setBackground(Color.WHITE);
      vv.getRenderContext().setEdgeLabelTransformer(
              new ToStringLabeller&lt;Edge&gt;());
      vv.getRenderContext().setEdgeShapeTransformer(
              new EdgeShape.Line&lt;Node, Edge&gt;());
      vv.getRenderContext().setVertexLabelTransformer(
              new ToStringLabeller&lt;Node&gt;());
      vv.getRenderer().getVertexLabelRenderer()
              .setPosition(Renderer.VertexLabel.Position.S);
  
      vv.addGraphMouseListener(new ClickNode(gui, vv));
  
      final DefaultModalGraphMouse&lt;Node, Edge&gt; graphMouse = new DefaultModalGraphMouse&lt;Node, Edge&gt;();
  
      graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
  
      vv.setGraphMouse(graphMouse);
  
      final GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
  
      return gzsp;
  }
  
  /**
   * Recursively add all nodes and edges to the tree.
   * 
   * @param node
   *            The parent node
   * @param tree
   *            The tree visualization
   */
  private static void addChildren(Node node, DelegateTree&lt;Node, Edge&gt; tree) {
      for (int i = 0; i &lt; node.getChildren().size(); i++) {
          tree.addChild(new Edge(node.getChildren().get(i).getEdgeLabel()), node, node
          .getChildren().get(i));
          addChildren(node.getChildren().get(i), tree);
      }
  }
  </code></pre>