Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding Image in Javafx

Tags:

java

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.

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

like image 604
Jatin Avatar asked Feb 04 '13 08:02

Jatin


1 Answers

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());
like image 182
Jatin Avatar answered Oct 23 '22 01:10

Jatin