我尝试在首次呈现窗格时显示通知。 这是我的控制器初始化方法的代码。
@Override
public void initialize(URL location, ResourceBundle resources) {
Notifications.create()
.title("Title Text")
.text("Hello World 0!")
.showWarning();
}
通知未显示且应用退出,我收到以下跟踪:
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at com.project.App.showMainView(App.java:325)
at com.project.App.hideSplash(App.java:297)
at com.project.App.access$1(App.java:295)
at com.project.App$2.run(App.java:221)
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)
Caused by: java.lang.NullPointerException
at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:334)
at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:322)
at org.controlsfx.control.Notifications.show(Notifications.java:269)
at org.controlsfx.control.Notifications.showWarning(Notifications.java:235)
at com.project.controllers.admin.myController.initialize(myController.java:100)