Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想加载一个存在于应用程序目录之外的图像,例如:
好的:url = Person.class.getResource("user_info.png").toString();
url = Person.class.getResource("user_info.png").toString();
高:url = Person.class.getResource("C:/images/user_info.png").toString();
url = Person.class.getResource("C:/images/user_info.png").toString();
我的情况是:我有很多应用程序在运行时需要的图像(>1000),我想创建一个包含所有图像的目录,然后从应用程序访问它。
配置:Netbeans 7.2、JavaFX 2.2。
对于本地路径使用file:/前缀,对于 web 你可以只使用 URL:
file:/
Image image = new Image("file:/c:/images/user_info.png");