title: JavaFX TilePane setPrefColumn/Row methods not working?
body: <p>I'm trying to make a Suduko board in JavaFX. I heard TilePane is especially good for this because the entire idea behind TilePane is that each 'Tile' is of uniform size. Great, that's exactly how a Suduko board, chess board, checkers, Tic Tac Toe, Battleship, etc. Sounds like TilePane is the must have pane for any kind of board game app. </p>
  
  <p>Or is it? </p>
  
  <pre><code>import javafx.application.Application;
  import javafx.application.Platform;
  import javafx.geometry.Pos;
  import javafx.scene.Scene;
  import javafx.scene.control.TextField;
  import javafx.scene.control.TextFormatter;
  import javafx.scene.control.TextFormatter.Change;
  import javafx.scene.image.Image;
  import javafx.scene.layout.TilePane;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  public class SudukoSolver extends Application
  {
      Stage window;
      Scene scene;
      private final int TEXTFIELD_WIDTH = 32;
      private final int TEXTFIELD_HEIGHT = 32;
  
      @Override public void start(Stage window) throws Exception
      {       
          this.window = window;
          window.setTitle("Suduko Solver");
          window.setOnCloseRequest(e -&gt; closeProgram());
  
          // Does setting this to false defeat the purpose of TilePane?
          window.setResizable(false); 
  
          VBox root = new VBox(); 
          //root.setAlignment(Pos.CENTER);
  
          TilePane tiles = new TilePane();    
          tiles.setAlignment(Pos.CENTER);
  
          // Does not appear to do anything.
          tiles.setPrefColumns(9);
          tiles.setPrefRows(9);
  
          // Add all the tiles to the Pane.
          root.getChildren().add(tiles);
  
          for (int i = 0; i &lt; 81; i++)
          {
              TextField textBox = new TextField();
              textBox.setMinHeight(TEXTFIELD_HEIGHT);
              textBox.setMaxHeight(TEXTFIELD_HEIGHT);
              textBox.setMinWidth(TEXTFIELD_WIDTH);
              textBox.setMaxWidth(TEXTFIELD_WIDTH);
  
              textBox.setTextFormatter(new TextFormatter&lt;String&gt;((Change change) -&gt; 
              {
                  String newText = change.getControlNewText();
                  if (newText.length() &gt; 1) 
                  {
                      return null ;
                  }
                  else if (newText.matches("[^1-9]"))
                  {
                      return null;
                  }
                  else 
                  {
                      return change ;
                  }
              }));
  
              tiles.getChildren().add(textBox);
          }
  
  
          scene = new Scene(root, 600, 750);
          window.setScene(scene);
          window.show();
      }
  
      /**
       * This method is called when the user wishes to close the program.
       */
      private void closeProgram()
      {
          Platform.exit();
      }
  
      public static void main(String[] args)
      {
          launch(args);
      }
  }
  </code></pre>
  
  <p>Notice how clearly this is not a 9x9 grid. </p>
  
  <p><a href="https://i.stack.imgur.com/I3at0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I3at0.png" alt="enter image description here"></a></p>
  
  <p>Any help would be greatly appreciated. Thank you!</p>