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?
Introduction to JavaFX GUI. In Java, JavaFX is considered a Graphical User Interface (GUI) toolkit that helps create desktop applications and games.
JavaFX is an open source, next generation client application platform for desktop, mobile and embedded systems built with Java. It is offered as a cross-platform Java library and it delivers consistent graphical user interfaces across a wide range of operating systems and devices.
JavaFX is a set of graphics and media packages that enables developers to design, create, test, debug, and deploy rich client applications that operate consistently across diverse platforms.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With