我是JavaFx的新手,我了解到可以使用controlsfx创建通知。但是,在包含了该包并运行了通知代码之后,我得到了一个类未发现异常,而且我不知道如何解决该异常,因为研究后我在网上没有得到任何帮助。我正在使用JDK jdk1.8.0_20,Netbeans 8.0.2和controlsfx 8.40.14。下面是我创建通知的代码
Platform.runLater(() -> {
Notifications notifications = Notifications.create().title("Verification successful").text("User has been verified").graphic(null).hideAfter(Duration.seconds(2)).position(Pos.TOP_RIGHT);
notifications.show();
});
这是例外
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: javafx/scene/control/ButtonBar
at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:349)
at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:322)
at org.controlsfx.control.Notifications.show(Notifications.java:269)
at flock.express.VerificationController.lambda$ProcessCaptureResult$0(VerificationController.java:263)
at flock.express.VerificationController$$Lambda$304/1685872131.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/873652227.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/501263526.run(Unknown Source)
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$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/96639997.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.ButtonBar
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 15 more
答案 0 :(得分:0)
我下载了jdk1.8.0_181,由于我使用的是Netbeans,所以我将Netbeans.conf文件中的netbeans_jdkhome更改为可以使用,并且现在可以正常使用