title: GridPane in ScrollBar, stretch empty space
body: <p>I'am using javafx for building a GUI, including a GridPane with a MenuBar and another GridPane. I want that second GridPane to be scrollable, so I put it into a ScrollPane "new ScrollPane(grid2)", and added it to the first GridPane. Unfortunally, the content of the ScrollPane isn't streched horizontally anymore, if the window-size changes, what is needed.</p>
  
  <p>Here is a pic, which should clearify the problem:
  <a href="http://img5.fotos-hochladen.net/uploads/scrollpaneemptwjpv2084xm.png" rel="nofollow">http://img5.fotos-hochladen.net/uploads/scrollpaneemptwjpv2084xm.png</a>
  (cant use sof-tool, because reputation&lt;10)</p>
  
  <p>I want to have a big number of TitledPages, with a button in front of them, and which can be scrollable (unlike the menu, which should stay on top).</p>
  
  <p>If i just add the second GridPane to the first one, it is streched in correct way, so I wonder why the ScrollPane or its element cant be streched also, and how.</p>
  
  <p>I post you my code, thanks for reading this, and thanks for your effort!</p>
  
  <pre><code>package main;
  
  import javafx.application.Platform;
  import javafx.beans.value.ChangeListener;
  import javafx.beans.value.ObservableValue;
  import javafx.embed.swing.JFXPanel;
  import javafx.geometry.Bounds;
  import javafx.geometry.Insets;
  import javafx.scene.Scene;
  import javafx.scene.control.*;
  import javafx.scene.layout.GridPane;
  import javafx.scene.layout.Priority;
  import javafx.scene.layout.StackPane;
  import javafx.scene.layout.VBox;
  import javafx.scene.text.Text; 
  import javax.swing.JFrame;
  import javax.swing.SwingUtilities;
  
  public class MainGUI6 extends JFrame {
  
      private static final long serialVersionUID = -8824577253071530315L;
      JFXPanel panel;
      Scene scene;
      boolean wait = true;
  
      public MainGUI6() {
          panel = new JFXPanel();
          Platform.runLater(new Runnable() {
              @Override
              public void run() {
  
                  GridPane grid = new GridPane();
                  scene = new Scene(grid, 1000, 1000);
                  grid.setVgap(4);
                  grid.setPadding(new Insets(5, 5, 5, 5));
  
                  //Menu
                  final Menu menu1 = new Menu("Menu1");
                  final Menu menu2 = new Menu("Menu2");
                  final Menu menu3 = new Menu("Menu3");
                  MenuBar menuBar = new MenuBar();
                  menuBar.getMenus().addAll(menu1, menu2, menu3);
                  grid.add(menuBar, 0, 0);
                  grid.setHgrow(menuBar, Priority.ALWAYS);
  
                  //Second grid
                  GridPane grid2 = new GridPane();
  
                  //Buttons
                  Button b1 = new Button("ButtonI1");
                  Button b2 = new Button("ButtonI2");
                  Button b3 = new Button("ButtonI3");
                  grid2.add(b1, 0, 0);
                  grid2.add(b2, 0, 1);
                  grid2.add(b3, 0, 2);
  
                  //TitledPanes
                  TitledPane tp1 = new TitledPane("TitledPane1", new Button("Button1"));
                  TitledPane tp2 = new TitledPane("TitledPane2", new Button("Button2"));
                  TitledPane tp3 = new TitledPane("TitledPane3", new Button("Button3"));
                  grid2.add(tp1, 1, 0);
                  grid2.add(tp2, 1, 1);
                  grid2.add(tp3, 1, 2);
                  grid2.setHgrow(tp1, Priority.ALWAYS);
                  grid2.setHgrow(tp2, Priority.ALWAYS);
                  grid2.setHgrow(tp3, Priority.ALWAYS);
  
                  ScrollPane sp = new ScrollPane(grid2);
              grid.add(sp, 0, 1);
                  grid.setHgrow(sp, Priority.ALWAYS);
  
                  panel.setScene(scene);
                  wait = false;
              }
          });
          this.getContentPane().add(panel);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setSize(500, 500);
          this.setVisible(true);
      }
  
      public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                  new MainGUI6();
              }
          });
      }
  }
  </code></pre>