本文介绍了在Javafx中绑定图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Javafx应用程序中,我有一个库。我想要做的是,只要图像在文件夹中可用,它就应该在屏幕上显示图像。
In my Javafx application, I have a gallery. What I want to do is that, as soon as an Image is available available in a folder, it should show that Image on the screen.
无论如何都要绑定一个图像
在 IamgeView
中。就像任何其他字符串或属性一样?我可以拥有一个名为ImageProperty的东西,它将绑定到Image。因此,如果我更改ImageProperty中的图像,它将更新UI
Is there anyway to bind an Image
in an IamgeView
. Just like any other String or Property? I can have something called ImageProperty and it will be binded to the Image. So if I change the image in the ImageProperty, it will update the UI
推荐答案
完成。 ImageView有一个可以绑定ObjectProperty的Object属性。
Done. ImageView has an Object Property to which an ObjectProperty can be binded.
ie
private ObjectProperty<javafx.scene.image.Image> imageProperty = new SimpleObjectProperty<>();
@FXML
private ImageView imageDisplay;
Bindings.bindBidirectional(this.imageDisplay.imageProperty(), GlobalModel.getInstance().getProject().getImageProperty());
这篇关于在Javafx中绑定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!