6

可以在桌面上贴一个舞台吗?

我想把我的应用程序当作小部件,所以当它启动时,它应该显示在桌面的正上方,而不是在可能打开的当前应用程序的前面。

小部件的另一个条件是它在任务栏中没有条目。这也可能吗?

4

1 回答 1

6

我用 JavaFX 2.2 尝试过,结果如下:

因此,当它启动时,它应该显示在桌面的正上方,而不是在可能打开的当前应用程序的前面

调用stage.toBack将在任何其他窗口后面放置一个舞台。

我能够让一个窗口在大多数情况下始终保持在其他窗口后面(至少在 Mac 上)。为此,我在时钟应用程序中显示舞台之前添加了几个侦听器和过滤器。

stage.focusedProperty().addListener(new ChangeListener<Boolean>() {
  @Override
  public void changed(ObservableValue<? extends Boolean> observableValue, Boolean wasFocused, Boolean focused) {
    stage.toBack();
  }
});

stage.addEventFilter(MouseEvent.ANY, new EventHandler<MouseEvent>() {
  @Override
  public void handle(MouseEvent mouseEvent) {
    stage.toBack();
  }
});

现有的要求是能够设置舞台以始终处于领先地位。您可以创建一个新的相应请求,以使某个阶段始终落后。

小部件的另一个条件是它在任务栏中没有条目

在 Windows 上,我认为如果您将舞台样式初始化StageStyle.UTILITY,那么 Windows 不会在 Windows 任务栏中显示舞台图标。

I tried a couple of different stage styles on OS X and a little Java cup icon would always show in the OS X dock when I ran the app and (unlike windows) setting the icons for the stage did not get rid of the Java cup icon. Perhaps if you created a self-contained OS X application you could turn the icon off for it during the packaging step, or set the icon to a transparent image so that it would not be visible to the user.

You could also create a feature request for this (separate from the always to back one) in the JavaFX issue tracker. If you create any issues related to this, explain your use case and link back to this question.

于 2013-03-30T09:24:04.903 回答