不知道是什么导致它在我的视图上找不到“init”函数,所以我想我会在这里发帖,看看其他人是否有这个问题。
一切编译正常!然后当我运行我的程序时,我得到了这个错误:
java.lang.InstantiationException: com.my.tfx.app.InputView
at java.lang.Class.newInstance(Class.java:427)
at tornadofx.FXKt.find(FX.kt:372)
at tornadofx.FXKt.find$default(FX.kt:358)
at tornadofx.App.start(App.kt:80)
at com.my.tfx.app.UserInputUI.start(UserInputUI.kt:15)
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.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$5(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodException: com.my.tfx.app.InputView.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 13 more
不太确定是什么原因造成的。我有这样的设置:
class UserInputUI : App(InputView(SVGEnum.first, StringEnum.first, UserInput.validationFunctions)::class, UIStyles::class) {
init {
reloadStylesheetsOnFocus()
}
override fun start(stage: Stage) {
super.start(stage)
stage.minWidth = 1024.0
stage.minHeight = 768.0
stage.maxWidth = 2560.0
stage.maxHeight = 1440.0
}
}
class InputView(val s: SVGEnum, val q: StringEnum, val valFunArray : ArrayList<(String)-> Boolean>) : View() {
override val root = stackpane {
//contents ommitted cause they're super long and I dont think its relevant,
//but I can add it in if requested
}
}
有任何想法吗?或者这是一个错误?谢谢!