How to add pictures to a javaFX 2.0 netbeans project

懵懂的女人 提交于 2019-12-07 13:48:23

问题


Hello and thank you for your time. I am new to Netbeans and I am using the Netbeans 7.1 RC1 version of Netbeans. The problem I am running into is that I seem unable to add images to the project. I am designing a web app in JavaFX 2.0 and need a jpg picture for my background. I need to know how to add this picture to the Netbeans file system to be able to call it from my program. Any help is appreciated. Thanks again


回答1:


Easiest way is to put it directly into src folder, they you would be able to refer to it from your JavaFX application by next code:

ImageView iv = new ImageView(new Image(getClass().getResourceAsStream("/image.png")));



回答2:


ImageView iv = new ImageView(new Image(getClass().getResourceAsStream("/image.png")));

it is showing error Image is an abstract class not be instantiated so how we can immplement it help



来源:https://stackoverflow.com/questions/8435518/how-to-add-pictures-to-a-javafx-2-0-netbeans-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!