In JavaFX, is binding an alternative to action-listener?

前提是你 提交于 2019-12-11 01:59:54

问题


I was wondering if in JavaFX, binding can be an alternative to action listener/events ? Can we handle all actions with binding instead of event handling ?


回答1:


No, binding is not an alternative to event handlers.

You could bind event properties to different event handlers, but then you would be using both technologies, not one or the other.

Generally you use binding for synchronizing data values and event handlers for running code on some event.

As an alternative to a bind call to set the value of dependent property, you can use change listeners to react on a change and trigger arbitrary code which could set the value of a dependent property. A change listener is different from an event handler. Change listeners and invalidation listeners can be used as an alternative to a binding but not vice versa in a general case.



来源:https://stackoverflow.com/questions/19610581/in-javafx-is-binding-an-alternative-to-action-listener

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