Showing Notifications without a owner

Issue #200 closed
Fabyan Alexander Belz Hesse
created an issue

I'm working in a background service aplication and using Notifications to interact with the user as status messages. When I try to show a Notification, it throws:

Caused by: java.lang.NullPointerException: Owner window must not be null at javafx.stage.PopupWindow.validateOwnerWindow(PopupWindow.java:916) at javafx.stage.PopupWindow.show(PopupWindow.java:412) at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:437)

When I execute the code:

    @Override
    public void start(Stage stage) throws Exception {
         Notifications.create().title("Title").text("Text").position(Pos.BOTTOM_RIGHT).show();
    }

Different from Dialogs, Notifications uses PopUpWindow instead of Stage, so it requires a owner... Is there some workaround for it?

Comments (8)

  1. Fabyan Alexander Belz Hesse reporter

    Yes, i'm not openning any stage, just a notification, if I open a stage and close/hide it, the notification doesn't appear. As workaround, i've created a invisible utility stage and placed it in a "far far away X,Y" (i'm not proud of it).

  2. Jonathan Giles

    Realistically, this is the best approach (although it could probably be transparent, etc too). It would probably be good for ControlsFX to do this itself if no stage was found that it could use for an ownerless notification.

  3. Log in to comment