如何解决当我使用fxml运行Tornado时出错Javafx / Kotlin
当我运行Application.kt时,出现此错误:
class Application :App(){
override val primaryView=Calculator::class
override fun start(stage: Stage) {
importStylesheet("/styleCSS.css")
stage.isResizable=false
super.start(stage)
}
我收到此错误
Fxml代码:
<?xml version="1.0" encoding="UTF-8"?>
<?override val root : BorderPane by fxml("/Application.fxml")?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Button?>
<VBox id="calculator"
xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml">
<Label fx:id="display" id="display"/>
<HBox>
<Button text="C"/>
<Button text="+/-"/>
<Button text="\%"/>
<Button text="/" styleClass="op"/>
</HBox>
<HBox>
<Button text="7"/>
<Button text="8"/>
<Button text="9"/>
<Button text="X" styleClass="op"/>
</HBox>
<HBox>
<Button text="4"/>
<Button text="5"/>
<Button text="6"/>
<Button text="-" styleClass="op"/>
</HBox>
<HBox>
<Button text="1"/>
<Button text="2"/>
<Button text="3"/>
<Button text="+" styleClass="op"/>
</HBox>
<HBox>
<Button text="0" styleClass="zero"/>
<Button text="="/>
</HBox>
</VBox>
如果有帮助,这里是完整的堆栈跟踪记录:
java.lang.IllegalStateException: component.javaClass.getResource(resource) must not be null
at tornadofx.ResourceLookup.url(Component.kt:1304)
at tornadofx.FX$Companion$fxmlLocator$1.invoke(FX.kt:114)
at tornadofx.FX$Companion$fxmlLocator$1.invoke(FX.kt:88)
at tornadofx.UIComponent.loadFXML(Component.kt:1119)
at tornadofx.UIComponent$fxml$1.<init>(Component.kt:1113)
at tornadofx.UIComponent.fxml(Component.kt:1112)
at tornadofx.UIComponent.fxml$default(Component.kt:1112)
at Calculator.<init>(Calculator.kt:5)
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:423)
at java.lang.Class.newInstance(Class.java:442)
at tornadofx.FXKt.find(FX.kt:434)
at tornadofx.FXKt.find$default(FX.kt:423)
at tornadofx.App.start(App.kt:83)
at Application.start(Application.kt:14)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$3(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
我试图在我的fxml中给出这个“ <?override val root : BorderPane by fxml("/Application.fxml")?>
”,但是它不起作用,我是否需要在“ kotlin / main”上使用Component.kt?
谢谢您能给我的帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。