Closed wendyunfa closed 9 months ago
Hi, thanks for this. Please can you include the image, fxml file and the minimal code that reproduces this issue so we can test and fix it as appropriate.
Thank you for your reply. Simply add the following code to the initUI method that extends the overrides of the GameApplication class to reproduce
protected void initUI() {
UI ui = getAssetLoader().loadUI("fxml/CitySubScene.fxml", () -> {});
getGameScene().addUI(ui);
}
Resource path of fxml assets/ui/fxml/CitySubScene.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.StackPane?>
<Pane xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0">
<children>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0">
<children>
<ImageView fitHeight="416.0" fitWidth="298.0" layoutX="61.0" layoutY="63.0">
<image>
<Image url="@CityDataWindow.png" />
</image>
</ImageView>
</children>
</AnchorPane>
</children>
</StackPane>
</Pane>
Resource path of IMageassets/ui/fxml/CityDataWindow.png
@wendyunfa thanks for the clear examples, this should now be fixed by the attached commit.
Let me know if it works.
To get the latest build, you can use this:
<dependencies>
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>21+dev-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
Thank you very much. After testing, this problem has been fixed.
Dear Almas: When I use loadUI to load the fxml generated by SceneBuilder drag and drop, if there is an Image tag in the fxml file, and the resource path that starts with @ will prompt
javafx.fxml.LoadException: Unknown path: 21
代码: