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

Flow, VBox and HBox layouts have very strange behaviors when I add components later

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: fx1.2.1
    • Fix Version/s: fx1.3
    • Component/s: javafx
    • Labels:

      Description

      Adding components (or just nodes) to layouts doesn't wok well. vertical vs. horizontal gets switched. New components don't get centered.

      May be related to RT-4522 and it's constellation.

      Here's some code to play with. Push the button to see the bug. Swap Flow for VBox and HBox to see more buggy behaviors.

      ---
      I don't see a JavaFX 1.2 in the version list.
      ---

      package growflow;

      import javafx.stage.Stage;
      import javafx.scene.Scene;

      import javafx.geometry.HPos;
      import javafx.geometry.VPos;
      import javafx.scene.layout.Flow;
      import javafx.scene.layout.LayoutInfo;

      import javafx.scene.Node;

      import javafx.scene.control.Button;
      import javafx.scene.shape.Polygon;
      import javafx.scene.paint.Color;
      import javafx.scene.control.Label;
      import javafx.scene.text.Font;

      def otherShape = Polygon {
              points : [ 0,0, 50,0, 50,50 ]
              fill: Color.BLUE
          }

      def otherComponent = Label {
              text: "Bigger, not centered"
              font: Font {
                  size:18
              }
              layoutInfo: LayoutInfo {
                  hpos: HPos.CENTER,
                  vpos: VPos.CENTER
              }

              override public function doLayout() {
                  java.lang.System.out.println("doLayout {boundsInParent}");
                  super.doLayout();

              }

          }

      def growFlowButton: Button =
                          Button {
                              text: "Grow"
                              layoutInfo: LayoutInfo {
                                  hpos: HPos.CENTER,
                                  vpos: VPos.CENTER
                              }
                              action: function(){
                                  flowContent = [growFlowButton, otherComponent];
                                                  }
                              }


      var flowContent : Node[] = [growFlowButton] on replace {
                                      for(node in flowContent) {
                                          java.lang.System.out.println("on replace {node} {node.boundsInParent}");
                                      }
                                  };

      def flow:Flow = Flow {
                              vertical: true;
                              nodeHPos: HPos.CENTER;
                              nodeVPos: VPos.CENTER;
                              layoutInfo: LayoutInfo {
                                  hpos: HPos.CENTER,
                                  vpos: VPos.CENTER
                              }
                              content: bind flowContent;

                              layoutX: bind (scene.width - flow.width) / 2;
                              layoutY: bind (scene.height - flow.height) / 2;
                          }


      def scene = Scene {
              width: 200
              height: 200
              content: [ flow ]
          }

      Stage {
          title : "GrowFlow"
          scene: scene
          }

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: