JavaFX: can you create a stage that doesn't show on the task bar and is undecorated?

前端 未结 6 816
予麋鹿
予麋鹿 2020-12-15 21:55

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

6条回答
  •  醉话见心
    2020-12-15 22:27

    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.

提交回复
热议问题