Instrument
クラスとController
クラスを作成しました。私はbindingBidirectional()
メソッドで大きな問題があります。それは私がプロパティAmountProperty
とバインドしようとしているときに私にエラーを与えるInstrument
クラスです。[JavaFx]このバインディングで何が問題になっていますか?
amount.valueProperty().bindBidirectional(instrument.amountProperty());
私はここで間違っていますか?
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());
}}
そしてInstrument
クラス:
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);
}
}
あなたはどのようなエラーを取得していますか? – assylias
http://stackoverflow.com/questions/24889638/javafx-properties-in-tableviewを参照してください。 –
java:bindBidirectional(javafx.beans.property.IntegerProperty)の適切なメソッドが見つかりません メソッドjavafx.beans.property.Property.bindBidirectional (javafx.beans.property.Property.Property)は適用されません (引数の不一致; javafx.beans.property.IntegerPropertyはjavafx.beans.property.Property に変換できません) メソッド –
Rocky3582