'How to display Images from Internet in JavaFX(not working)?

I want to take the url of a image from a API, which I did. I also get the URL of the image that I want, but the image doesn't display in the JavaFX Scene.

String json2=readUrl("https://imsea.herokuapp.com/api/1?q=moon");
images.Images i=gson.fromJson(json2,images.Images.class);
System.out.println(i.getResult1());
String path = i.getResult1();
Image image = new Image(new FileInputStream(i.getResult1()));
img_spaceObject.setImage(image);

*Update: I did that by first downloading the image and then displaying it, but I wanted a short version, as I mentioned before.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source