Reputation: 1154
I've the following class:
public class Model {
...
private SimpleStringProperty currency;
public SimpleStringProperty currencyProperty() {
if(currency == null){
currency = new SimpleStringProperty();
}
return currency;
}
...
}
And I bind (textfield) to above class as follows:
@FXMLController("view.fxml")
public class Controller {
...
@FXML
private TextField tf_acc_num;
@Inject
private Model model;
...
@PostConstruct
public void init(){
tf_acc_num.textProperty().bindBidirectional(model.currencyProperty());
...
}}
It is Ok. What about binding comboboxes and checkboxes? Assume Combobox as
@FXML
private ComboBox<String> cb_currency;
and I put values in it inside init()
method
cb_currency.getItems().addAll(
"USD", "EUR", "RUB"
);
Upvotes: 2
Views: 2041
Reputation: 209339
Does
cb_currency.valueProperty().bindBidirectional(model.currencyProperty());
work?
Upvotes: 4