File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed
main/kotlin/com/almasb/fxgl/app/services
kotlin/com/almasb/fxgl/app
resources/fxglassets/ui/fxml Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -785,7 +785,7 @@ private class UIAssetLoader : AssetLoader<UI>(
785
785
val controller = (params as UIParams ).controller
786
786
787
787
params.url.openStream().use {
788
- val loader = FXMLLoader ()
788
+ val loader = FXMLLoader (params.url )
789
789
loader.setController(controller)
790
790
val root = loader.load<Parent >(it)
791
791
controller.init ()
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import com.almasb.fxgl.test.InjectInTest
17
17
import com.almasb.fxgl.test.RunWithFX
18
18
import com.almasb.fxgl.texture.getDummyImage
19
19
import com.almasb.fxgl.ui.UIController
20
+ import javafx.scene.image.ImageView
20
21
import org.hamcrest.CoreMatchers.*
21
22
import org.hamcrest.MatcherAssert.assertThat
22
23
import org.junit.jupiter.api.Assertions.*
@@ -321,6 +322,21 @@ class AssetLoaderServiceTest {
321
322
assertThat(ui.root, `is `(notNullValue()))
322
323
}
323
324
325
+ @Test
326
+ fun `Load UI with image element` () {
327
+ val controller = object : UIController {
328
+ override fun init () {
329
+ }
330
+ }
331
+
332
+ val ui = assetLoader.loadUI(" fxml/test_ui_with_image.fxml" , controller)
333
+
334
+ val imageView = ui.root.lookup(" #imageView" ) as ImageView
335
+
336
+ assertThat(imageView, `is `(notNullValue()))
337
+ assertThat(imageView.image, `is `(notNullValue()))
338
+ }
339
+
324
340
@Test
325
341
fun loadCSS () {
326
342
var css = assetLoader.loadCSS(" test.css" )
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+
3
+ <?import javafx .scene.image.Image?>
4
+ <?import javafx .scene.image.ImageView?>
5
+ <?import javafx .scene.layout.Pane?>
6
+
7
+ <Pane xmlns =" http://javafx.com/javafx/21" xmlns : fx =" http://javafx.com/fxml/1" >
8
+ <ImageView id =" imageView" >
9
+ <Image url =" @test.png" />
10
+ </ImageView >
11
+ </Pane >
You can’t perform that action at this time.
0 commit comments