Using Notification leaves ghost window on taskbar

Issue #44 new
Ron Siven
created an issue

I use the NotifierBuilder to create a notifier, and then create a Notification using the NotificationBuilder. When I invoke the notifier.notify(notification) method, it creates a ghost window on the Windows taskbar that doesn't disappear when the Popup disappears.

    private Notification.Notifier notifier;

    notifier = NotifierBuilder.create()
            .popupLocation(Pos.BOTTOM_RIGHT)
            .popupLifeTime(Duration.millis(10_000))
            .height(120.0d)
            .build();

    Notification errorNotification = NotificationBuilder.create()   
        .title(resourceBundle.getString("title") + " - " + resourceBundle.getString("error"))
        .message(notification.getErrorMessage())
        .image(Notification.ERROR_ICON)
        .build();

    Platform.runLater(() -> notifier.notify(errorNotification));

Comments (12)

  1. Ron Siven reporter

    Thanks for your timely response! I have a tight timeline for my project, and this notification tool is exactly what I need. So, thank you for that as well!

    I just pulled your changes, and still see the same behavior. What I have done for now is change the showPopup method to hide the stage if the popups list is empty. So, from this:

        timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
            POPUP.hide();
            popups.remove(POPUP);
            fireNotificationEvent(new NotificationEvent(NOTIFICATION, Notifier.this, POPUP, NotificationEvent.HIDE_NOTIFICATION));
        }));
    

    to this:

        timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
            POPUP.hide();
            popups.remove(POPUP);
            if (popups.isEmpty()) {
                stage.hide();
            }
            fireNotificationEvent(new NotificationEvent(NOTIFICATION, Notifier.this, POPUP, NotificationEvent.HIDE_NOTIFICATION));
        }));
    

    I also added an icon to the stage. :)

  2. Ron Siven reporter

    Gerrit,

    It appears as though I'm not the only one. I see that someone else commented about a similar issue a couple of weeks ago on the YouTube video for this feature of Enzo: https://youtu.be/82m0tNfx7pE

    Could it be a Windows 10 thing? I kind of doubt it. It's most likely a Windows or a Java thing. If we could specify more than one StageStyle like TRANSPARENT and UTILITY, this would not be a problem.

    I'm happy to assist in any way I can. I'll keep seeking answers in the meantime unless you find an answer before that.

    Thanks again!

  3. Ron Siven reporter

    This is a total hack. But, by setting stage.setY(-100); and stage.initStyle(StageStyle.UTILITY); in the initGraphics() method of the Notification.Notifier enum, the window doesn't appear on the taskbar. Nor is it visible to the user as it is off of the viewable area of the srceen. ¯_(ツ)_/¯

  4. Gerrit Grunwald repo owner

    Yep I played with the same hack but did not like it much which is the reason why it is not in :)
    So it seems that this problem only occurs on Windows, problem for me is that I do not have a windows machine available, just OS X and Linux.
    Will try to find a way...

  5. Gerrit Grunwald repo owner

    You might want to try the following in Notifier:

    private void initGraphics() {
        scene = new Scene(new Region());
        scene.setFill(null);
        scene.getStylesheets().add(getClass().getResource("notifier.css").toExternalForm());
    
        stage = new Stage();
        stage.setMinWidth(0);
        stage.setMinHeight(0);
        stage.setMaxWidth(0);
        stage.setMaxHeight(0);
        stage.setWidth(0);
        stage.setHeight(0);
        stage.initModality(Modality.NONE);
    
        stage.setResizable(false);
        //stage.initStyle(StageStyle.TRANSPARENT);
        stage.initStyle(StageStyle.UTILITY);
        stage.setScene(scene);
        stage.setAlwaysOnTop(true);
    }
    
  6. Ron Siven reporter

    I tried the code from above, but to no avail. The window does not appear on the taskbar, but it appears on the desktop as a tiny window with only a close ('X') button.

  7. Log in to comment