【发布时间】:2019-05-28 13:04:49
【问题描述】:
在我的 javaFX 应用程序中配置本地图像的路径时遇到了一些麻烦。 我想在我的按钮上使用图标,但它不适用于本地图像,只能用于外部资源。这是我的代码:
<Button fx:id="magicWangButton" mnemonicParsing="false" onAction="#magicWang" text="Magic wang">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<!--<Image url="/fxml/img/magic-wang.png" />-->
<Image url="https://i.stack.imgur.com/y1evM.png" />
<!--<Image url="/fxml/img/site-logo.png" />-->
<Image url="img/magic-wang.png"/>
</image>
</ImageView>
</graphic>
</Button>
这个字符串很好用:
<Image url="https://i.stack.imgur.com/y1evM.png" />
,但其他... 我的图片位于路径:resources/fxml/img/ 位于 fxml 目录中的所有 fxml 文件。 我看到了其他问题和答案,但它使用 java 文件中的配置,但这不是我要找的。p>
【问题讨论】: