JavaFx imageview无法解决文件错误

我一直在努力解决有关JavaFx ImageView类的问题。用fxml编写的代码

  <ImageView fitHeight="634.0" fitWidth="1204.0" layoutX="38.0" layoutY="83.0" pickOnBounds="true" preserveRatio="true" rotate="-8.0">
     <image>
        <Image url="@\PCI%20logoRYB.png" />
     </image></ImageView>

,并且一直显示此错误

Cannot resolve file '\PCI%20logoRYB.png'

我使用场景生成器创建了所有这些图像,并且图像与fxml文件位于同一位置

nbayjj 回答:JavaFx imageview无法解决文件错误

尝试从您的网址中删除\,如下所示。图片必须位于资源目​​录中。

<ImageView fitHeight="634.0" fitWidth="1204.0" layoutX="38.0" layoutY="83.0" pickOnBounds="true" preserveRatio="true" rotate="-8.0">
 <image>
    <Image url="@PCI%20logoRYB.png" />
 </image></ImageView>
,

如果您在添加图像之类的资源后使用 eclipse IDE ,则需要清理项目以重新加载添加到项目中的所有新资源文件。

enter image description here

本文链接:https://www.f2er.com/1270580.html

大家都在问