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

ScrollPane content.getParent() returns null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8
    • javafx
    • Win7, Java8b116

      When setting the content on a scrollpane, content.getParent() returns null as long as the stage is not visible - see test below.

      public class ScrollPaneContentParentTest extends Application
      {
        private Pane scrollContent;
        
        public static void main(String[] args)
        {
          Application.launch(args);
        }

        @Override
        public void start(Stage stage)
        {
          Parent root = createContent();
          System.err.println("Parent (shouldn't be null): " + scrollContent.getParent());
          Scene scene = new Scene(root, 500, 500);
          stage.setScene(scene);
          stage.show();
          System.err.println("Parent: " + scrollContent.getParent());
        }
        
        private Parent createContent()
        {
          ScrollPane scroller = new ScrollPane();
          scrollContent = new FlowPane(10,10);
          scrollContent.setPrefSize(500, 2000);
          Button button = new Button("MyButton");
          scrollContent.getChildren().add(button);
          scroller.setContent(scrollContent);
          return scroller;
        }
      }

            jgiles Jonathan Giles
            wzberger Wolfgang Zitzelsberger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: