scenebuilder layer classnotfound

故事扮演 提交于 2019-12-02 18:27:50

问题


I'm having problem. I used SceneBuilder and JavaFX. When I used layer in SceneBuilder and I tried to load it in java. I've got the error message below:

javafx.fxml.LoadException: 
/C:/Projects/des_project2/target/classes/view/user/UserMainView.fxml
    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
    at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
    at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    at controller.UserController.<init>(UserController.java:26)
    at controller.MainController.<init>(MainController.java:23)
    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 sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
    at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
    at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
    at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at window.MainApp.start(MainApp.java:18)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.layout.Layer
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
    at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
    at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
    ... 36 more

It says cause by: Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.layout.Layer and in my fxml file says it cannot resolve the Layer com.gluonhq.charm.glisten.layout.Layer.

Could you help me on this? Thanks in advance.


回答1:


You can use all the components included in the Container or Control panels from Scene Builder in any JavaFX project (as well as those in the other panels like Menu, Shapes, 3D, ...), since those are built-in JavaFX components.

But those included in the Gluon Mobile panel are not regular JavaFX components.

These components are included in the Gluon Mobile library, and you can make use of it in your project as well, providing you include the proper dependencies.

The best way to do it is using the Gluon IDE plugin on your favorite IDE (NetBeans, IntelliJ or Eclipse). Install the plugin and create a new project, it will include the Gluon Mobile dependencies:

dependencies {
    compile 'com.gluonhq:charm:4.3.0'
}

You can select the Gluon Mobile - MultiView with FXML or Glisten-Afterburner templates. Both make use of FXML, and you can use Scene Builder 8.3.0 to design the Views for your project.

Note that you will be able to run this project on desktop and also on mobile (Android and iOS), using the same codebase.

Be aware that the library is not free, but you can fully explore it without a license.



来源:https://stackoverflow.com/questions/41530842/scenebuilder-layer-classnotfound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!