如何在Javafx中显示Internet的图像(无法正常工作)?
我想从API中获取图像的URL。我还获得了想要的图像的URL,但是图像在Javafx场景中没有显示。
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);
*更新:我首先下载图像然后显示它来做到这一点,但是我想要一个简短的版本,如前所述。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用
所需的URL到构造函数。
To quote the Javadoc:
Just pass your desired URL to the constructor.