将 JavaFX 变量绑定到 Java 变量/对象
我正在编写一个包含 Java Swing GUI 面板的 JavaFX 应用程序(具体来说,它是 OpenBlocks 工作区)。
我想从 JavaFX 端检测 Java Swing 面板中发生的某些事件并响应它们。我在JavaFX环境中有一个事件监听器,当该监听器“听到”一个事件时,我想让一些JavaFX GUI对象可见,所以我正在考虑尝试将这些对象的“可见”属性绑定到一些变量Java当感兴趣的事件发生时将更新的变量;但我尝试进行此绑定,但它对我不起作用。
所以我的一般问题是:有没有办法将 JavaFX 变量绑定到 Java 变量/对象,如果是的话,这是如何完成的?
预先感谢您对此的任何帮助! :)
I am writing a JavaFX application that contains a Java Swing GUI panel (it's the OpenBlocks workspace to be specific).
I want to detect certain events that occur in the Java Swing panel from the JavaFX side and respond to them. I have an event listener in the JavaFX environment, and when that listener "hears" an event, I want to make some JavaFX GUI object visible, so I was thinking of trying to bind the "visible" property of these objects to some variable Java variable that will update when the events of interest occur; but I tried to do this binding, and it is not working for me.
So my general question is: Is there a way to bind a JavaFX variable to a Java variable/object, and if so, how is this done?
Thank you in advance for any help on this!!! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 JavaFX 2.0 中,您可以使用
javafx.beans.binding.ObjectProperty
(及相关)类来执行此操作。In JavaFX 2.0 you can do this the
javafx.beans.binding.ObjectProperty<T>
(and related) classes.