title: JavaFX TableView - Center the Content of a Table Column
body: <p>I have a big Problem.</p>
  
  <p>I try to center the Content of a TableColumn in a TableView.</p>
  
  <p>I already tried everything I found on the net but really nothing of that worked!</p>
  
  <p>Is anyone there who had/has the same problem? any Solutions?</p>
  
  <p>Hope for help!</p>
  
  <p>Edit: </p>
  
  <p>Well I was able to center the content of a static cell with this code:</p>
  
  <pre><code>tc_customer.setCellFactory(new Callback&lt;TableColumn&lt;TvAccounting, String&gt;, TableCell&lt;TvAccounting, String&gt;&gt;() {
                  @Override
                  public TableCell&lt;TvAccounting, String&gt; call(TableColumn&lt;TvAccounting, String&gt; p) {
                      TableCell&lt;TvAccounting, String&gt; tc = new TableCell&lt;TvAccounting, String&gt;();
                      tc.setAlignment(Pos.CENTER);
                      tc.setText("SOMETEXT");
                      return tc;
                  }
              });
  </code></pre>
  
  <p>But the content should come from a database and i really hav no idea how to get the data from the ObservableList Object that i use in the <code>TABLEVIEWNAME.setItems</code> method...</p>
  
  <p>I first used this code:</p>
  
  <pre><code>tc_customer.setCellValueFactory(new PropertyValueFactory&lt;TvAccounting, String&gt;("Customer"));
  </code></pre>
  
  <p>but there was no way to center that content!</p>
  
  <p>Please could anyone help me?</p>
  
  <p>Edit:</p>
  
  <p>Thanks to this Great Answer, I did it!</p>
  
  <p>Code below:</p>
  
  <pre><code>tc_customer.setCellFactory(new Callback&lt;TableColumn&lt;TvAccounting, String&gt;, TableCell&lt;TvAccounting, String&gt;&gt;() {
                  @Override
                  public TableCell&lt;TvAccounting, String&gt; call(TableColumn&lt;TvAccounting, String&gt; p) {
                      TableCell&lt;TvAccounting, String&gt; tc = new TableCell&lt;TvAccounting, String&gt;(){
                          @Override
                          public void updateItem(String item, boolean empty) {
                              if (item != null){
                                  setText(item);
                              }
                          }
                      };
                      tc.setAlignment(Pos.CENTER);
                      return tc;
                  }
              });
  
              tc_customer.setCellValueFactory(new PropertyValueFactory&lt;TvAccounting, String&gt;("Customer"));
  </code></pre>
  
  <p><strong>BEST THANKS!!!</strong></p>