更新时间:2022-06-13 01:10:02
设置资产
目录作为资源目录,然后从/drawIcon.png位置加载图像作为资源:
Set the assets
directory as a resource directory and then load the image as a resource from the location "/drawIcon.png":
URL url = getClass().getResource("/drawIcon.png");
Image image = ImageIO.read(url);
如果你想创建一个javafx图片:
In case you want to create a javafx Image:
Image image = new Image("/drawIcon.png");
在这种情况下,同时将该文件夹标记为资源文件夹。
In this case, also, mark that folder as resource folder.
此处有更多信息: https: //docs.oracle.com/javafx/2/api/javafx/scene/image/Image.html