Error saving image in an ImageView object with JavaFX and sceneBuilder


I'm making a simple graphical desktop application for image management and, I'm using JavaFX, in addition to its sceneBuilder. The idea is, by giving a button that a FileChooser appears, to choose the image and to show a new window with all the background image on it the problem is that by doing it gives me an error that I can not identify.
Edit: I have discovered that if I open the image in the same window there is no error, only when doing it in a new one.
This is my code.



asked by Danielmagox 17.11.2018 в 17:21

1 answer


For javafx avoid using the AWT tools (BufferedImage) There is a new class for it.

import javafx.scene.image.Image;

Image image1 = new Image("/flower.png", true);
Image image2 = new Image("my/res/flower.png", 100, 150, false, false);
Image image3 = new Image("", 100, 0, false, false);
Image image4 = new Image("file:flower.png", 0, 100, false, false);

This can then be placed in an ImageView. My suggestion is that you review

answered by 26.11.2018 в 01:07