javaFX Tableview Данные не видны
Я попробовал все, чтобы заполнить TableView данными. Следующий код вставляет новую строку в таблицу, но данные не отображаются в таблице. Я пытался найти объяснение этому без успеха.
Пожалуйста помоги. Я могу'т что не так.
В controller.java
@FXML private TableView tempTable;
@FXML private TableColumn columnTime;
@FXML private TableColumn columnTempOne;
@FXML private TableColumn columnTempTwo;
@FXML private TableColumn columnTempThree;
@FXML protected void initialize() {
columnTime = new TableColumn();
columnTime.setCellValueFactory(
new PropertyValueFactory("Time"));
columnTempOne = new TableColumn();
columnTempOne.setCellValueFactory(
new PropertyValueFactory("Temp 1"));
columnTempTwo = new TableColumn();
columnTempTwo.setCellValueFactory(
new PropertyValueFactory("Temp 2"));
columnTempThree = new TableColumn();
columnTempThree.setCellValueFactory(
new PropertyValueFactory("Temp 3"));
tempDataList = FXCollections.observableArrayList();
tempDataList.add(new TempTableData("0",3.0f, 4f, 5f));
tempTable.setItems(tempDataList);
}
TempTableData.java
открытый класс TempTableData {
private final SimpleStringProperty time;
private final SimpleFloatProperty dataSensorOne;
private final SimpleFloatProperty dataSensorTwo;
private final SimpleFloatProperty dataSensorThree;
public TempTableData(String time, float dataSensorOne, float dataSensorTwo, float dataSensorThree){
this.time = new SimpleStringProperty(time);
this.dataSensorOne = new SimpleFloatProperty(dataSensorOne);
this.dataSensorTwo = new SimpleFloatProperty(dataSensorTwo);
this.dataSensorThree = new SimpleFloatProperty(dataSensorThree);
}
public String getTime() {
return time.get();
}
public void setTime(String time) {
this.time.set(time);
}
public float getDataSensorOne() {
return dataSensorOne.get();
}
public void setDataSensorOne(float dataSensorOne) {
this.dataSensorOne.set(dataSensorOne);
}
public float getDataSensorTwo() {
return dataSensorTwo.get();
}
public void setDataSensorTwo(float dataSensorTwo) {
this.dataSensorTwo.set(dataSensorTwo);
}
public float getDataSensorThree() {
return dataSensorThree.get();
}
public void setDataSensorThree(float dataSensorThree) {
this.dataSensorThree.set(dataSensorThree);
}
public String toString(){
String string = String.format("[time: %s | dataSensorOne: %f |dataSensorTwo: %f |dataSensorThree: %f ]",
time.get(), dataSensorOne.get(), dataSensorTwo.get(), dataSensorThree.get());
return string;
}
}