title: JavaFX labels height
body: <p>I'm developing software in JavaFX and JavaFX Scene Builder.</p>
  
  <p>I have a grid pane with 2 columns. Actually in each of the cells there are labels.
  In the first column of the table the text inside the label is a default constant, in the second one the text can change.</p>
  
  <p>The problem is that if the text variable is too long, it's automatically truncated. </p>
  
  <p>How to start a new line trimming the text and re-sizing the height of the rows in the grid pane?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thanks to @fabian issues, this is the solution to the initial question.
  In addiction is necessary to set the fx:id of each element into Scene Builder.</p>
  
  <pre><code>@FXML private GridPane gridPane;
  @FXML private Text text1;
  @FXML private Text text2;
  @FXML private Text text3;
  
  
  private void setGridRowHeight(GridPane gpName, int numRow, double height){
      ObservableList&lt;RowConstraints&gt;  rows = gpName.getRowConstraints();
      rows.get(numRow).setMinHeight(32);
      rows.get(numRow).setPrefHeight(height);
      rows.get(numRow).setMaxHeight(height);
  }
  
  
  private void addTextListener(final GridPane gridPane, final Text text){
  
      text.textProperty().addListener(new ChangeListener&lt;String&gt;() {
          @Override
          public void changed(ObservableValue&lt;? extends String&gt; observable, String oldValue, String newValue) {
              scrollPane.setFitToHeight(true);
              text.setWrappingWidth( gridPane.getColumnConstraints().get(1).getPrefWidth() );
              setGridRowHeight(gridPane, gridPane.getRowIndex(text), text.getLayoutBounds().getHeight() );
          }
      });
  }
  
  
  @FXML public void initialize() {
      addTextListener(gridPane, text1);
      addTextListener(gridPane, text2);
      addTextListener(gridPane, text3);
  }    
  </code></pre>