2 Replies Latest reply: Dec 6, 2012 10:06 PM by abhinay_a RSS

    Adding tree to VBox On button press error

    abhinay_a
      Hey,

      I want to populate a VBox section on button press, so i am call the following code and adding it to the left pane or border.

      public VBox addVBox()
      {

      VBox vbox = new VBox();
      vbox.setPadding(new Insets(10)); // Set all sides to 10
      vbox.setSpacing(8); // Gap between nodes


      TreeItem<String> itemClient = new TreeItem<String> ("Client");
      itemClient.setExpanded(true);

      TreeItem<String> itemClient1 = new TreeItem<String> ("Place Order");
      itemClient1.getChildren().add(itemClient1);
      TreeItem<String> itemClient2 = new TreeItem<String> ("Edit Order");
      itemClient2.getChildren().add(itemClient2);
      TreeItem<String> itemClient3 = new TreeItem<String> ("Cancel Order");
      itemClient3.getChildren().add(itemClient3);

      TreeItem<String> itemVendor = new TreeItem<String> ("Vendor");
      itemVendor.setExpanded(true);

      TreeItem<String> itemVendor1 = new TreeItem<String> ("Place Order");
      itemVendor1.getChildren().add(itemVendor1);
      TreeItem<String> itemVendor2 = new TreeItem<String> ("Edit Order");
      itemVendor1.getChildren().add(itemVendor2);
      TreeItem<String> itemVendor3 = new TreeItem<String> ("Cancel Order");
      itemVendor1.getChildren().add(itemVendor3);


      TreeView<String> treeClient = new TreeView<String> (itemClient);
      TreeView<String> treeVendor = new TreeView<String> (itemVendor1);

      vbox.getChildren().addAll(treeClient,treeVendor);

      return vbox;
      }

      But, unfortunately, while executing this code, m getting the following issue:

      java.lang.RuntimeException: java.lang.StackOverflowError
           at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:251)
           at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
           at com.sun.glass.ui.View.notifyMouse(View.java:922)
           at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
           at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
           at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
           at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.StackOverflowError
           at javafx.beans.binding.ObjectExpression.getValue(ObjectExpression.java:47)
           at javafx.scene.control.TreeItem.getParent(TreeItem.java:588)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:729)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
           at javafx.scene.control.TreeItem.buildEventDispatchChain(TreeItem.java:730)
      Exception in thread "JavaFX Application Thread"

      I can see that TreeItem.Build is called may times and the stack overflows, but y ??
      Any pointers as to where m doing wrong ??