Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8106878

HBox VBox - Do not work after an insert of a CustomNode/Group containing them

XMLWordPrintable

      Code including an HBox spaces correctly when its class is statically included within the Stage.
      When the exact class is 'insert' ed dynamically into the Stage - there is no spacing in the HBox - all nodes are overlayed in the first spot

      we have this as a test example MainSceneGroup can extend Group or CustomNode - it still fails the same

      public class MainSceneGroup extends Group{
          init {
              content = [
                  Rectangle {
                      width: 200,
                      height: 200
                      fill: Color.BLACK
                  }
                  HBox {
                      spacing: 20
                      content: [
                          Rectangle {
                              width: 20,
                              height: 20
                              fill: Color.WHITE
                          }
                          Rectangle {
                              width: 20,
                              height: 20
                              fill: Color.WHITE
                          }
                          Rectangle {
                              width: 20,
                              height: 20
                              fill: Color.WHITE
                          }
                      ]
                  }
              ]
          }
      }



      Now with a simple Main.fx

      public def myStage = Stage {
          title: "HBox Test"
          resizable: false
          scene: Scene {
              width: 400
              height: 400
              content: MainSceneGroup{
              }
          }
      };



      It works like a charm - All three White Rectangles are nicely spaced

      Now in my app - I followed the nice example of the WhiteOut Game and liked the idea of a transition screen. Splash --> Main Scene
      So I started like this
      I put an insert into the main Scene -
      None of my HBox or VBox ever spaced themselves correctly - they always overlayed themselves !

      So - back to the test
      Swap the Main.fx above with this one

      public def myStage = Stage {
          title: "HBox Test"
          resizable: false
          scene: Scene {
              width: 400
              height: 400
          }
      };
       
      function run() {
         var mainScene = MainSceneGroup {};
         insert mainScene into Main.myStage.scene.content;
      }



      Now - All the HBox white rectangles are on top of each other - no spacing

            amfowler Anne Fowler (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: