Update
Attached example code that shows the problem. I noticed that this happens when:
- Displaying the table inside the grid panel with another control (e.g. Combobox), so the tableview headers are aligned with the grid
- The first row of the table looks empty.
I am trying to use a TableView to display the name and TextField pair using the following code (Java8u66)
FXML
<TableView fx:id="AttributeValueTableView" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" GridPane.columnSpan="2" GridPane.rowIndex="1">
<columns>
<TableColumn fx:id="AttributeTableColumn" editable="false" minWidth="50.0" prefWidth="200.0" text="Attribute"/>
<TableColumn fx:id="ValueTableColumn" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="400.0" text="Value"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
controller
public class Controller implements Initializable {
@FXML
private TableView<AttributeValuePair> AttributeValueTableView;
@FXML
private TableColumn<AttributeValuePair, String> AttributeTableColumn;
@FXML
private TableColumn<AttributeValuePair, Object> ValueTableColumn;
private ObservableList<AttributeValuePair> valuePairs = FXCollections.observableArrayList();
@Override
public void initialize(URL location, ResourceBundle resources) {
AttributeTableColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
ValueTableColumn.setCellFactory(param -> new AttributeValueCell());
valuePairs.add(new AttributeValuePair("Attribute1"));
valuePairs.add(new AttributeValuePair("Attribute2"));
valuePairs.add(new AttributeValuePair("Attribute3"));
valuePairs.add(new AttributeValuePair("Attribute4"));
valuePairs.add(new AttributeValuePair("Attribute5"));
valuePairs.add(new AttributeValuePair("Attribute6"));
AttributeValueTableView.setItems(valuePairs);
}
private class AttributeValueCell extends javafx.scene.control.TableCell<AttributeValuePair, Object> {
@Override
protected void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
AttributeValuePair valuePair = (AttributeValuePair) this.getTableRow().getItem();
if (empty || valuePair == null) {
setGraphic(null);
setText(null);
} else {
TextField t = new TextField();
setGraphic(t);
}
}
}
}
I noticed that it works fine as long as there are blank lines, as in the following figure

( ), visible, .
, , - .
, ,
