我有一个这样的课程:
class SomeObject{
public SimpleDoubleProperty Vre = new SimpleDoubleProperty(0);
public SimpleDoubleProperty Vim = new SimpleDoubleProperty(0);
public SimpleDoubleProperty Vabs = new SimpleDoubleProperty(0);
SomeObject(){
Label results_label = new Label();
results_label.textProperty().bind(Vabs.asString());
}
}
我希望每当我更改属性Vre
或Vim
时,Vabs
的值都会更新为Vre+j*Vim
的模块,该模块会生成标签{{1显示复数的模块。
感谢。
答案 0 :(得分:3)
只需创建所需的绑定:
vAbs.bind(Bindings.createDoubleBinding(
() -> Math.sqrt(vRe.get() * vRe.get() + vIm.get() * vIm.get()),
vRe, vIm);