如何将图片添加到javaFX 2.0 netbeans项目中 [英] How to add pictures to a javaFX 2.0 netbeans project
问题描述
您好,谢谢您的时间。我是Netbeans的新手,我正在使用Netbeans的Netbeans 7.1 RC1版本。我遇到的问题是我似乎无法将图像添加到项目中。我正在JavaFX 2.0中设计一个Web应用程序,需要一个jpg图片作为我的背景。我需要知道如何将此图片添加到Netbeans文件系统,以便能够从我的程序中调用它。任何帮助表示赞赏。再次感谢
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
推荐答案
最简单的方法是将其直接放入src文件夹,您可以从JavaFX中引用它应用下一个代码:
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")));
这篇关于如何将图片添加到javaFX 2.0 netbeans项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!