6

is it possible to stick a stage to the desktop?

I want to behave my application as widget, so when it starts it should be displayed right above the desktop and not in front of the current application which might be opened.

The other condition for a widget would be that it has no entry in the taskbar. Is that also possible?

Gundon
  • 2,081
  • 6
  • 28
  • 46

1 Answers1

6

I tried this with JavaFX 2.2 and had the following results:

so when it starts it should be displayed right above the desktop and not in front of the current application which might be opened

Calling stage.toBack will place a stage behind any other windows.

I was able to get a window to always stay behind other windows most of the time (at least on a mac). To do this, I added a couple of listeners and filters before showing the stage in a clock application.

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();
  }
});

There is an existing request for an ability to set a stage to always be on top. You could create a new corresponding request for an ability for a stage to always be behind.

The other condition for a widget would be that it has no entry in the taskbar

On Windows, I think if you init the stage style to StageStyle.UTILITY, then Windows does not show an icon for the stage in the Windows taskbar.

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.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • This solution worked perfectly for me on windows, though I don't need to hide the window from the taskbar. I think now, with JavaFX 8, where we have an `alwaysOnTop` functionality, there should be a similar thing to make the window always stay behind. Does anybody know if there is an issue of the official issue tracker yet? – machinateur Mar 30 '15 at 09:41
  • I don't know if an feature request has been created. If you wish, you can search the issue tracker and create one if there is not already an existing feature request. – jewelsea Mar 30 '15 at 17:06