在 FXML ImageView 中加载图像?
Loading image inside FXML ImageView?
我的 FXML 中有以下图像:
<ImageView>
<image>
<Image url="@/Icons/myImage.png" />
</image>
</ImageView>
我的xml文件在里面:
src/Core/View
另一方面,我的图标在里面:
src/Core/View/Icons
为什么我收到无效资源错误...在类路径中找不到?我不确定我做错了什么或如何使路径工作。
您需要将 url="@/Icons/myImage.png"
更改为 url="@Icons/myImage.png"
,删除开头的 /
我的 FXML 中有以下图像:
<ImageView>
<image>
<Image url="@/Icons/myImage.png" />
</image>
</ImageView>
我的xml文件在里面:
src/Core/View
另一方面,我的图标在里面:
src/Core/View/Icons
为什么我收到无效资源错误...在类路径中找不到?我不确定我做错了什么或如何使路径工作。
您需要将 url="@/Icons/myImage.png"
更改为 url="@Icons/myImage.png"
,删除开头的 /