我试图在JavaFx中实现pop upp通知,我正在使用这个库,并根据该教程编写了以下代码:
String title = "Well done boy!!";
String message = "You've successfully created your first Tray Notification";
TrayNotification tray = new TrayNotification();
tray.setTitle(title);
tray.setMessage(message);
tray.setNotificationType(NotificationType.SUCCESS);
tray.showAndWait();但是代码抛出了一个异常:
由: com.sun.javafx.application.PlatformImpl.runLater(Unknown源( com.sun.javafx.application.PlatformImpl.runLater(Unknown Source) )( com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(Unknown Source) ( com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(Unknown Source) (javafx.scene.control.Control)引起的: java.lang.IllegalStateException:未初始化的工具包。(未知源).
有什么建议吗?
请注意,原始代码示例是实现类似
tray.setNotification(notification);如果通知是
但是有些情况下我不能导入类
Notification notification = Notifications.SUCCESS;发布于 2017-04-03 08:01:39
尝试使用构造函数来创建.ıt对我来说是这样的。您是否从模块设置中添加了库?
例如:
TrayNotification tray = new TrayNotification("Test", "mesaj", NotificationType.SUCCESS);
tray.showAndWait();https://stackoverflow.com/questions/42717624
复制相似问题