So I have created Instrument
class and Controller
class. I have big problem with bindingBidirectional()
method. It gives me an error when i'm trying to bind Combobox
property with AmountProperty
in Instrument
class.
amount.valueProperty().bindBidirectional(instrument.amountProperty());
What am I doing wrong here?
Controller class
public class Controller implements Initializable{
@FXML
private ComboBox<Integer> amount = new ComboBox<>();
ObservableList<Integer> amountOptions = FXCollections.observableArrayList(0, 5, 10, 25, 50);
Instrument instrument = new Instrument();
@Override
public void initialize(URL location, ResourceBundle resources) {
amount.getItems().addAll(amountOptions);
//THIS ONE IS NOT WORKING
amount.valueProperty().bindBidirectional(instrument.amountProperty());
}}
And Instrument
class:
public class Instrument {
private IntegerProperty amount = new SimpleIntegerProperty();
public int getAmount() {
return amount.get();
}
public IntegerProperty amountProperty() {
return amount;
}
public void setAmount(int amount) {
this.amount.set(amount);
}
}