a.disableProperty().bind(b.visibleProperty()) causes invalid element rendering in Java FX 10

。_饼干妹妹 提交于 2019-12-05 20:03:31

First, I'd just like to confirm that I am observing the same behavior as you.

  • Windows 10 x64 Home
  • Java 1.8.0_172 x64 -- Works as expected
  • Java 10.0.1 x64 -- Fails (shows as disabled but is not actually disabled)

This appears to be a bug and you should report it as such.


Possible Workaround

I found that the nodes in question will be rendered correctly if you add to following code to all affected nodes:

node.disableProperty().addListener((observable, oldValue, newValue) -> {
    if (!newValue) { // if no longer disabled
        node.applyCss();
    }
});

This could become tedious if you have a lot of nodes that can be disabled and are subject to the same sequence of events as described in your question. It may be prudent to create some type of utility method to handle this.

Edit

I found that the order of when you make propertyProvider invisible affects the workaround I provided. If you make propertyProvider invisible after you display the new TitledPane then, when you go back to the other TitledPane, the TextField and Button still render as disabled when they are not. Haven't found a way around that yet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!