I'm trying to create a stage that doesn't appear on the Windows task bar and is undecorated (no borders and no close/minimize/maximize buttons). My end goal is to create a tray icon application that will pop up notification windows.
It's similar to this question where I want the behavior of both StageStyle.UTILITY (which prevents the stage from showing on the task bar) and StageStyle.TRANSPARENT (which is a completely undecorated window).
The referenced question doesn't work for me because I don't have a parent stage from which to make a modal window. Any ideas on how to get this to work? Thanks
You can have multiple stages displayed in a JavaFX program.
The JavaFX Stage class is the top level JavaFX container. The primary Stage is constructed by the platform. Additional Stage objects may be constructed by the application. Stage objects must be constructed and modified on the JavaFX Application Thread.
Showing a Stage The difference between the JavaFX Stage methods show() and showAndWait() is, that show() makes the Stage visible and the exits the show() method immediately, whereas the showAndWait() shows the Stage object and then blocks (stays inside the showAndWait() method) until the Stage is closed.
I was able to workaround this issue with the following code:
Stage stage = new Stage();
stage.initStyle(StageStyle.UTILITY);
stage.setMaxHeight(0);
stage.setMaxWidth(0);
stage.setX(Double.MAX_VALUE);
StageStyle.UTILITY will avoid creating a taskbar icon. I set the width and height to 0 make the window small and then use stage.setX(Double.MAX_VALUE) to place it far off screen so it doesn't show up. It's a bit hokey, but it seems to work fine.
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