title: JavaFX - Get GridPane to fit parent
body: <p>I have a simple GridPane showing a couple of labels and a button, but I cannot seem to get it to fit the parent StackPane. How would I go forth and make it so that it fills whatever container it is in?</p>
  
  <pre><code>    GridPane g = new GridPane();
      g.add(new Label("Categories"),0,0);
      g.add(new Label("Content"),1,0);        
      Button newCat = new Button("New Category");
      newCat.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
          @Override public void handle(ActionEvent e) {
              System.out.println("Clicked");
          }
      });       
      g.add(newCat,0,1);
      g.setGridLinesVisible(true);
      StackPane root = new StackPane();
      root.getChildren().add(g);        
      Scene scene = new Scene(root, 300, 250);  
      primaryStage.setScene(scene);
      primaryStage.show();
  </code></pre>
  
  <p>UI is really not my forte and any help would be appreciated. </p>