Problem with binding
Hello,
When trying to work with properties and binding, i find this error. Can you help me to understand the origin of the problem.
java.lang.RuntimeException: A bound value cannot be set.
at javafx.beans.property.IntegerPropertyBase.set(Unknown Source)
at com.sun.javafx.binding.BidirectionalBinding$BidirectionalIntegerBinding.changed(Unknown Source)
at com.sun.javafx.binding.BidirectionalBinding$BidirectionalIntegerBinding.changed(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(Unknown Source)
at javafx.beans.property.IntegerPropertyBase.fireValueChangedEvent(Unknown Source)
at javafx.beans.property.IntegerPropertyBase.markInvalid(Unknown Source)
at javafx.beans.property.IntegerPropertyBase.set(Unknown Source)
at IntField$2.changed(IntField.java:125)
at IntField$2.changed(IntField.java:106)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(Unknown Source)
at javafx.scene.control.TextInputControl$TextProperty.fireValueChangedEvent(Unknown Source)
at javafx.scene.control.TextInputControl$TextProperty.markInvalid(Unknown Source)
at javafx.scene.control.TextInputControl$TextProperty.invalidate(Unknown Source)
at javafx.scene.control.TextInputControl$TextProperty.access$200(Unknown Source)
at javafx.scene.control.TextInputControl$1.invalidated(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(Unknown Source)
at javafx.scene.control.TextField$TextFieldContent.insert(Unknown Source)
at javafx.scene.control.TextInputControl.replaceText(Unknown Source)
at com.sun.javafx.scene.control.skin.TextFieldSkin.replaceText(Unknown Source)
at com.sun.javafx.scene.control.behavior.TextFieldBehavior.replaceText(Unknown Source)
at com.sun.javafx.scene.control.behavior.TextInputControlBehavior.defaultKeyTyped(Unknown Source)
at com.sun.javafx.scene.control.behavior.TextInputControlBehavior.callAction(Unknown Source)
at com.sun.javafx.scene.control.behavior.BehaviorBase.callActionForEvent(Unknown Source)
at com.sun.javafx.scene.control.behavior.TextInputControlBehavior.callActionForEvent(Unknown Source)
at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$KeyHandler.process(Unknown Source)
at javafx.scene.Scene$KeyHandler.access$1800(Unknown Source)
at javafx.scene.Scene.impl_processKeyEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.keyEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(Unknown Source)
at com.sun.glass.ui.View.handleKeyEvent(Unknown Source)
at com.sun.glass.ui.View.notifyKey(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "JavaFX Application Thread"
For more clarification, my IntField class is a class that extends TextField on which i do some treatment to support int int the text field:
<code>
line 106: this.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observableValue, String oldValue, String newValue) {
if (newValue == null || "".equals(newValue)) {
value.setValue(0);
return;
}
final int intValue = Integer.parseInt(newValue);
if (intField.minValue > intValue || intValue > intField.maxValue) {
textProperty().setValue(oldValue);
}
line 125: value.set(Integer.parseInt(textProperty().get()));
}
});
}