使窗口的任务栏为JavaFX 2 Stage闪烁

时间:2011-12-22 11:40:29

标签: javafx-2

我在甲骨文的论坛上发布了这个,但没有回应,所以我在这里尝试。 有没有办法让窗口的特定舞台的任务栏闪烁? 我正在构建一个IM客户端,我希望任务栏在新消息到达时闪烁。 使用Swing JFrame我可以通过调用setVisible(true)来实现这一点;但JavaFX2的阶段表现不一样。 任何帮助或指导将不胜感激。 感谢。

2 个答案:

答案 0 :(得分:4)

我没有在所有系统上测试它,但是在Win7上如果你运行下一个应用程序并改变焦点,它将通过调用Stage.toFront()来眨眼

public class Blinker extends Application {

    @Override
    public void start(final Stage stage) throws Exception {
        stage.setTitle("i'll blink");
        stage.setScene(new Scene(new Group(new Text(25,25,"blink-blink"))));
        stage.show();

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

            @Override
            public void handle(ActionEvent t) {
                stage.toFront();
            }
        })).cycleCount(Timeline.INDEFINITE).build().play();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

答案 1 :(得分:0)

我使用下面的方法,它工作正常。

if (! stage.isFocussed()){
stage.toFront();
}

相关问题