如何在javaxf中绑定属性和双字段

如何在javaxf中绑定属性和双字段,java,javafx,Java,Javafx,My rectangle mainFrame.widthProperty具有一个负责宽度的属性。我旋转了另一个矩形,并从shape.getShape.getBoundsInParent.getWidth类型Double中获取其宽度。我可以在这些值之间进行绑定吗 mainFrame.widthProperty().bind(rightShape.getShape().getBoundsInParent().getWidth()); 这不起作用我认为应该使用节点类中定义的boundsInParen

My rectangle mainFrame.widthProperty具有一个负责宽度的属性。我旋转了另一个矩形,并从shape.getShape.getBoundsInParent.getWidth类型Double中获取其宽度。我可以在这些值之间进行绑定吗

mainFrame.widthProperty().bind(rightShape.getShape().getBoundsInParent().getWidth());
这不起作用

我认为应该使用节点类中定义的boundsInParentProperty进行绑定

试试这个

mainFrame.widthProperty().bind(Bindings.createDoubleBinding(() -> {
    return rightShape.getShape().getBoundsInParent().getWidth();
}));

几乎您需要将boundsInParentProperty作为依赖项传递给createDoubleBinding,否则它将不会在属性更改时更新。请更详细。请提供一个示例来说明此问题。