I have a class with the getters/setters for interacting with an underlying device driver. The getter reads data from device and the setter writes data to device. I would add a FX property to this class in order to bind to a GUI controls. I build the property by using JavaBeanPropertyBuilder and it's works. But the property value can be changed not only on GUI side but also on a device side, so I need update the properties by a timer and I want force invalidate the properties in order to update all bindings. Is it possible?
UPD with code example:
class MyDevice {
public double getSpeed() {
return (double)driver.getParameter("speed");
}
public void setSpeed(double value) {
driver.setParameter("speed", value);
}
private DoubleProperty speed = new JavaBeanDoublePropertyBuilder().bean(this).name("speed").build();
public DoubleProperty speedProperty() {
return speed;
}
}
Now, I bind MyDevice::speedProperty
to GUI control and if a value has been changed on the driver side I want something like speedProperty.invalidate()
to force handle all registered listeners and update the bindings. (I know about changes on the driver side by a timer's querying of a device status, for example, but not all available parameters.)
The
fireValueChangedEvent
method can be used to notify theJavaBeanDoubleProperty
that the underlying data has been changed.The short answer is yes. However without you being more specific on your use case, there is just some general advice:
InvalidationListener
` to your property, which is called whenever the bound property changes it's valuebidirectional
, so that changes from either direction are reflected at the other side.ChangeListener
to theProperty
.