JavaFX 14中的通知

huangapple go评论73阅读模式
英文:

Notifications in JavaFX 14

问题

我知道我可以使用以下代码创建通知:

Notifications notificationBuilder = Notifications.create()
    .title(title)
    .text(content)
    .hideAfter(Duration.seconds(31536000))
    .position(Pos.BOTTOM_RIGHT)
    .onAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent a) {
            //
        }
    });

notificationBuilder.showInformation();

但是在 IntelliJ (JDK 11 和 JavaFX 14) 中,我找不到 Notifications 类。如何在 JavaFX 14 中创建通知?

英文:

I know I can create a notification with

Notifications notificationBuilder = Notifications.create()
                .title(title)
                .text(content)
                .hideAfter(Duration.seconds(31536000))
                .position(Pos.BOTTOM_RIGHT)
                .onAction(new EventHandler&lt;ActionEvent&gt;() {
                    @Override
                    public void handle(ActionEvent a) {
                        //
                    }
                });

        notificationBuilder.showInformation();

But in IntelliJ (JDK 11 and JavaFX 14)
I can't find the class Notifications.
How can I create a notification in JavaFX 14?

答案1

得分: 1

因为它似乎不属于其中任何一个。我能找到与此代码匹配的唯一类是controlsfx.bitbucket.io/org/controlsfx/control/…,它是ControlsFX项目的一部分。无论您使用哪个构建工具,都可以在此处找到它的依赖项:mvnrepository.com/artifact/org.controlsfx/controlsfx

  • ajc2000
英文:

> Because it doesn't look like it's part of either one. Only matching
> class I could find for this code is
> controlsfx.bitbucket.io/org/controlsfx/control/…, which is part of the
> ControlsFX project. Here is the dependency for whatever build tool you
> are using: mvnrepository.com/artifact/org.controlsfx/controlsfx

– ajc2000

huangapple
  • 本文由 发表于 2020年8月5日 01:18:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63251962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定