j'ai suivi le long du guide pour l'utilisation TornadoFX FXML (https://github.com/edvin/tornadofx/wiki/FXML), mais je suis une erreur se:IllegalArgumentException lors de l'utilisation FXML
java.lang.IllegalArgumentException: FXML not found for class ui.view.BoardView
Voici ma vue BoardView.kt:
class BoardView : View() {
override val root: BorderPane by fxml()
val hello: Label by fxid()
init {
hello.text = "Hello World"
}
}
et voici le fichier FXML (dans le même paquet, ui.view) *
<BorderPane xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1">
<padding>
<Insets top="20" right="20" bottom="20" left="20" />
</padding>
<center>
<HBox alignment="CENTER" spacing="10">
<Label fx:id="hello">
<font>
<Font size="20"/>
</font>
</Label>
</HBox>
</center>
</BorderPane>
Voici la trace complète de la pile si elle aide:
java.lang.IllegalArgumentException: FXML not found for class ui.view.BoardView
at tornadofx.UIComponent$fxml$1.<init>(Component.kt:360)
at tornadofx.UIComponent.fxml(Component.kt:353)
at tornadofx.UIComponent.fxml$default(Component.kt:353)
at ui.view.BoardView.<init>(BoardView.kt:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at tornadofx.FXKt.find(FX.kt:238)
at tornadofx.App.start(App.kt:29)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
J'ai essayé donner des arguments à FXML(), de "BoardView" à "BoardView.fxml" pour déplacer le fichier FXML dans src/main/resources. Je ne pouvais rien voir d'évident en regardant le fichier source Component.kt.
Merci pour toute aide que vous pouvez me donner.
Avez-vous essayé de taper TornadoFX dans google ou youtube? beaucoup d'exemples là-bas. – Nevets17
Avez-vous configuré BoardView.fxml pour avoir la classe contrôleur de la classe BoardView? Je ne vois pas de racine dans le fxml, pas de contrôleur donc je suppose que non. Jetez un coup d'oeil sur cela. :) – GOXR3PLUS
@ GoXR3Plus Dans TornadoFX, il n'est pas nécessaire de fournir le paramètre ** fx: controller ** dans le fichier fxml. Le contrôleur est assigné dynamiquement par le framework lorsqu'il charge le fxml. Ceci est inversé à partir de JavaFX, où le FXMLLoader va instancier le contrôleur. Ici, le contrôleur est d'abord instancié, puis le FXML est chargé. –