Reputation: 31724
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.
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
Upvotes: 6
Views: 9196
Reputation: 31724
Done. ImageView has an Object Property to which an ObjectProperty can be binded.
i.e.
private ObjectProperty<javafx.scene.image.Image> imageProperty = new SimpleObjectProperty<>();
@FXML
private ImageView imageDisplay;
Bindings.bindBidirectional(this.imageDisplay.imageProperty(), GlobalModel.getInstance().getProject().getImageProperty());
Upvotes: 10