1

I've already looked at similar questions here (for example, Javafx PropertyValueFactory not populating Tableview) and double checked that I'm not just making a spelling/capitalization error. That seems not to be the case. The behavior I'm observing is that my TableView is reflecting the change in the underlying model - rows get added - but none of the cells are actually drawing their data.

Here's the data object class:

public class HistoryEntry {
private SimpleIntegerProperty _gameNumber = new SimpleIntegerProperty();
private SimpleStringProperty _playerOneMove = new SimpleStringProperty();
private SimpleStringProperty _playerTwoMove = new SimpleStringProperty();

public HistoryEntry(int gameNumber, String p1Move, String p2Move) {
    _gameNumber.set(gameNumber);
    _playerOneMove.set(p1Move);
    _playerTwoMove.set(p2Move);
}

Integer getGameNumber() {
    return Integer.valueOf(_gameNumber.get());
}

String getPlayerOneMove() {
    return _playerOneMove.get();
}

String getPlayerTwoMove() {
    return _playerTwoMove.get();
}
}

And here's the controller, setting up the TableView:

...
private ObservableList<HistoryEntry> _historyList;
@FXML private TableView<HistoryEntry> _history;
@FXML private TableColumn<HistoryEntry, Integer> _gameNumber;
@FXML private TableColumn<HistoryEntry, String> _playerMove;
@FXML private TableColumn<HistoryEntry, String> _opponentMove;
@FXML private Button _debugHEButton;
...
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        _historyList = FXCollections.observableList(new ArrayList<>());
        _history.setItems(_historyList);
        _gameNumber.setCellValueFactory(new PropertyValueFactory<>("GameNumber"));
        _playerMove.setCellValueFactory(new PropertyValueFactory<>("PlayerOneMove"));
        _opponentMove.setCellValueFactory(new PropertyValueFactory<>("PlayerTwoMove"));
    }
...
    public void handleDebugHE(ActionEvent actionEvent) {
        int row = _historyList.size() + 1;
        _historyList.add(new HistoryEntry(row, "BOGUS 1", "BOGUS 2"));
    }
Stephen B.
  • 396
  • 2
  • 19

0 Answers0