scenebuilder图层classnotfound [英] scenebuilder layer classnotfound

查看:156
本文介绍了scenebuilder图层classnotfound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了问题。我使用了SceneBuilder和JavaFX。当我在SceneBuilder中使用图层时,我尝试在java中加载它。我收到以下错误消息:

  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(F XMLLoader.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(原生方法)
at com.sun.glass.ui.win.WinApplicati on.lambda $ null $ 148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
引起: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

它表示原因:引起:java.lang.ClassNotFoundException:com .gluonhq.charm.glisten.layout.Layer 并在我的fxml文件中说它无法解析图层 com.gluonhq.charm.glisten.layout.Layer



你能帮我解决这个问题吗?
提前致谢。

解决方案

您可以使用Scene Builder中Container或Control面板中包含的所有组件任何JavaFX项目(以及其他面板中的项目,如Menu,Shapes,3D,......),因为它们是内置的JavaFX组件。



Gluon Mobile 面板中包含的内容不是常规JavaFX组件。





这些组件包含在Gluon Mobile 中,您可以制作在项目中也使用它,为你提供适当的依赖。



最好的方法是使用Gluon IDE 插件。安装插件并创建一个新项目,它将包含Gluon Mobile依赖项:

 依赖项{
compile'c​​om .gluonhq:魅力:4.3.0'
}

你可以选择胶子手机 - 带有FXML或Glisten-Afterburner模板的MultiView。两者都使用FXML,您可以使用Scene Builder 8.3.0为您的项目设计视图。



请注意,您将能够在桌面上运行此项目以及使用相同代码库的移动设备(Android和iOS)。



请注意,该库不是免费的,但您可以在没有许可证的情况下完全浏览它。 / p>

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.

解决方案

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.

这篇关于scenebuilder图层classnotfound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆