Last active
March 23, 2018 15:40
-
-
Save sbeitzel/752779132e1b31073fb2011cc18f3986 to your computer and use it in GitHub Desktop.
How to get cell values to update properly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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