Skip to content

Instantly share code, notes, and snippets.

@sbeitzel
Last active March 23, 2018 15:40
Show Gist options
  • Save sbeitzel/752779132e1b31073fb2011cc18f3986 to your computer and use it in GitHub Desktop.
Save sbeitzel/752779132e1b31073fb2011cc18f3986 to your computer and use it in GitHub Desktop.
How to get cell values to update properly
@FXML public TableView<ServerInstance> _serverTable;
@FXML public TableColumn<ServerInstance, Number> _smtpPort;
@FXML public TableColumn<ServerInstance, Number> _popPort;
@FXML public TableColumn<ServerInstance, Number> _messageCount;
@FXML public TableColumn<ServerInstance, Number> _receivedCount;
// ...
@Override
@SuppressWarnings("unused")
public void initialize(URL location, ResourceBundle resources) {
_servers = FXCollections.observableList(new ArrayList<>());
_serverTable.setItems(_servers);
_smtpPort.setCellValueFactory(param -> param.getValue().getSmtpPort());
_popPort.setCellValueFactory(param -> param.getValue().getPopPort());
_messageCount.setCellValueFactory(param -> param.getValue().getMessageCount());
_receivedCount.setCellValueFactory(param -> param.getValue().getTotalReceived());
// ...
}
/* And then, in ServerInstance: */
private SimpleIntegerProperty _smtpPort = new SimpleIntegerProperty();
// ...
@SuppressWarnings("unused")
public ObservableValue<Number> getSmtpPort() {
return _smtpPort;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment