title: Let Window scroll down in JavaFX
body: <p>So I am trying to learn Java now that I know JavaScript and PHP. I am working in Netbeans with JavaFX and I am trying to create a program that creates 5 buttons. (This is modifying the code that comes with Netbeans when creating a new JavaFX Application.) If I change the y-argument of the scene to be less than the y of all of the buttons, it will not display the remaining buttons and it will not be able scroll down. This is what I have so far. How do I enable it to scroll down so all buttons can be seen? I know that I can just change the scene back to its old height but I want to learn about scrolling with JavaFX.</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.GridPane;
  import javafx.stage.Stage;
  import javax.swing.JScrollPane;
  
  public class JavaFXApplication1 extends Application {
  
      @Override
      public void start(Stage primaryStage) {
          GridPane root = new GridPane();
          Button[] btn=new Button[5];
          for(int i=0;i&lt;5;i++){
              btn[i] = new Button();
              btn[i].setText(i+"");
              GridPane.setRowIndex(btn[i],i); 
              root.getChildren().addAll(btn[i]);
              btn[i].setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
              @Override
              public void handle(ActionEvent event) {
                  System.out.println("This is a button");
              }
          });
  
          }
  
          Scene scene = new Scene(root, 300, 50);
  
          primaryStage.setTitle("Hello World!");
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
  
      public static void main(String[] args) {
          launch(args);
      }
  
  }
  </code></pre>