0
widthProperty()
のデータを正しく使用する方法textField
?textField、JavaFxのデータで矩形を描画する
widthRectangle.textProperty().bindBidirectional(rectangleObj.getWidthRectangleValue());
rectangle.widthProperty().bind(rectangleObj.getWidthRectangleValue());
上記は機能しません。たぶん私はそれを適切に使う方法をどこかに見つけるでしょう?
編集:
public class RectangleObj {
private StringProperty widthRectangleValue = new SimpleStringProperty();
private StringProperty heightRectangleValue = new SimpleStringProperty();
public StringProperty getWidthRectangleValue(){
return widthRectangleValue;
}
public void setWidthRectangleValue(StringProperty widthRectangleValue){
this.widthRectangleValue = widthRectangleValue;
}
public StringProperty getHeightRectangleValue(){
return heightRectangleValue;
}
public void setHeightRectangleValue(StringProperty heightRectangleValue){
this.heightRectangleValue = heightRectangleValue;
}
}
。
public class ControllerParametersForRectangle implements Initializable {
@FXML
Rectangle rectangle;
@FXML
TextField widthRectangle;
@FXML
TextField heightRectangle;
RectangleObj rectangleObj = new RectangleObj();
@Override
public void initialize(URL location, ResourceBundle resources) {
widthRectangle.textProperty().bindBidirectional(rectangleObj.getWidthRectangleValue());
rectangle.widthProperty().bind(rectangleObj.getWidthRectangleValue());
}
}
あなたの質問は正確には何ですか? –
私は 'bind()'の代わりに何を作るべきかわかりません – Bartek
"うまくいかない"とはどういう意味ですか? 'rectangleObj'が何であるのか、' getWidthRectangleValue() 'が返すものをテレパシーで知っていると思われますか? [質問する](http://stackoverflow.com/help/how-to-ask)を読んでください。 –