在JavaFX中,绑定是动作侦听器的替代方法吗? [英] In JavaFX, is binding an alternative to action-listener?

查看:61
本文介绍了在JavaFX中,绑定是动作侦听器的替代方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在JavaFX中绑定是否可以替代动作侦听器/事件? 我们可以用绑定而不是事件处理来处理所有动作吗?

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 ?

推荐答案

否,事件处理程序.

您可以将事件属性绑定到不同的事件处理程序,但是随后您将同时使用这两种技术,而不是其中一种.

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.

这篇关于在JavaFX中,绑定是动作侦听器的替代方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆