CellValueFactory and CellFactory are two different things. CellValueFactory is used to specify where do the values come from, while CellFactory specifies how do they get displayed.
Use both at the same time. But in the setCellFactory
code you should not do setText
. Setting the text will be taken care of by the TableCell
code inside the updateItem()
method. This method will use the value that is provided from the ' cellValueFactory ' and take care of setting it inside its own label.
tc_customer.setCellFactory(
new Callback< TableColumn<TvAccounting, String>,
TableCell<TvAccounting, String>>()
{
@Override public TableCell<TvAccounting, String>
call(TableColumn<TvAccounting, String> p) {
TableCell<TvAccounting, String> tc =
new TableCell<TvAccounting, String>();
tc.setAlignment(Pos.CENTER);
// tc.setText("SOMETEXT"); This line should be removed
return tc;
}
}
);