Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
587 views
in Technique[技术] by (71.8m points)

java - How to lock JavaFX fullscreen mode?

I am currently working on a volunteer sign-in application, and need to prevent any attempts to tamper with the computer. As a start, I set the application to fullscreen, easily enough. Then I tried to set the exit key combination for the window to null, but JavaFX automatically defaults to the escape key in that case. I will have an admin section where the program can be exited using a password. Is there any way to effectively intercept any possible methods of exiting a JavaFX application's fullscreen state, or--better yet--temporarily suspend/lock other OS functions?

Edit--Using KeyCombination.NO_MATCH, I prevent the user from exiting fullscreen. However, the OS is still perfectly capable of exiting using standard key combos, or, in the case of OS X, simply by moving the mouse to the top of the screen and exiting using the program menu.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...