This discussion is archived
2 Replies Latest reply: Mar 13, 2013 1:47 AM by csh RSS

Problem with taskbar blinking of Stage (Win7)

csh Journeyer
Currently Being Moderated
I try to let a stage blink in the taskbar.

Obviously this can be achieved using the toFront() method, also mentioned here:
http://stackoverflow.com/questions/8603376/make-windows-taskbar-blink-for-javafx-2-stage

But, I have the problem, that after the first showing of the stage, the stage will not blink again, if you hide it.


Here is a sample test case. Run it and make sure, that you focus any other window. After 5 seconds a Stage popups up and it blinks. It will blink every 5 seconds, if you don't have the primary stage focussed.

If you close the stage, it will popup up again. But this time it does NOT blink.

Any solutions are appreciated!
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.animation.TimelineBuilder;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import javafx.util.Duration;

public class TestApp4 extends Application {
    public static void main(String[] args) {
        launch(args);
    }


    private Stage subStage;

    @Override
    public void start(final Stage stage) throws Exception {

        TimelineBuilder.create().keyFrames(new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent t) {
                if (subStage == null) {
                    subStage = new Stage();
                }
                subStage.show();
                subStage.toFront();
            }
        })).cycleCount(Timeline.INDEFINITE).build().play();

        Scene scene = new Scene(new Label("Wait"), 300, 300);
        stage.setScene(scene);
        stage.show();
    }
}
  • 1. Re: Problem with taskbar blinking of Stage (Win7)
    csh Journeyer
    Currently Being Moderated
    I've found out, that the problem of not blinking lies in the fact, that the window automatically receives focus, which is also not good for my use case.

    I want the window to show, but not getting focussed automatically, in order to not disturb the user at his current work. E.g. if you type in this text box (on this forum), you would suddenly continue typing in the new window (if it has a TextArea), which is annoying.

    If the window is shown for the first time, everything is fine. Every following times, it receives focus automatically.

    I tried to initOwner() with the parent window. I don't have the problem then, but another one: The window does not show as separate window in the task bar.

    Can you help here?
  • 2. Re: Problem with taskbar blinking of Stage (Win7)
    csh Journeyer
    Currently Being Moderated
    The issue is still present and annoying. Can somebody comment or help?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points