How to lock JavaFX fullscreen mode?

大憨熊 提交于 2019-12-02 01:40:52

I'm i missing something? i think its cheese.. like this

primaryStage.fullScreenProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable,
                Boolean oldValue, Boolean newValue) {
            if(newValue != null && !newValue.booleanValue())
                primaryStage.setFullScreen(true);
        }
    });

fullscreen nobody tempers till user presses the start button to obscure the UI you can prevent that though- but i will suggest try the following code only if you are about to off your pc

new Thread(new Runnable() {
        @Override
        public void run() {
            while(true){
               //in my initial try i didn't add sleep, 
               //and i ended up,turning off the pc,lost this post for a while
                try {
                    Thread.sleep(100); //buy little millieseconds
                } catch (InterruptedException e) {}

                Platform.runLater(()->{
                    primaryStage.toFront();
                    //bring your UI on top of everyone
                });
            }

        }
    }).start();

primaryStage is your Stage

Hope its what you want

primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!