The JDK 8u20 “Tap trap”
When switching MQTT.fx to JDK 8u20 I was nicked by the fix of RT-24658.
The fix definitely makes sense but may clash with my TabPaneDetacher approach.
In MQTT.fx the content of the Tabs is disabled as long the MQTT-Broker is not connected.
And I am using Property Bindings for this. E.g. in the PublishController “publishBox” is the root of the Publish-Tab content and it is bound to the brokerConnectedProperty()
:
publishBox.disableProperty().bind(model.brokerConnectedProperty().not());
This worked well until JDK 8u20 as now this leads into:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: A bound value cannot be set.
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:139)
at javafx.scene.Node.setDisable(Node.java:1539)
[...]
This is because each time when e.g. adding a Tab
to a TabPane
updateDisabled()
is called to explicitly SET the disabled value of the content also:
private void updateDisabled() { boolean disabled = isDisable() || (getTabPane() != null && getTabPane().isDisabled()); setDisabled(disabled); // Fix for RT-24658 - content should be disabled if the tab is disabled Node content = getContent(); if (content != null) { content.setDisable(disabled); } }
Options to deal with this:
Quit using Binding here and use ChangeListener
instead.
Or simply wrap the content root in another Pane.
Leave a Reply