如何锁定JavaFX全屏模式? [英] How to lock JavaFX fullscreen mode?

查看:443
本文介绍了如何锁定JavaFX全屏模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在制作志愿登录应用程序,并且需要防止任何篡改计算机的企图。首先,我将应用程序设置为全屏,足够轻松。然后我尝试将窗口的退出键组合设置为null,但在这种情况下,JavaFX会自动默认为转义键。我将有一个管理部分,可以使用密码退出程序。有没有办法有效拦截退出JavaFX应用程序全屏状态的任何可能方法,或者 - 更好的是 - 暂时暂停/锁定其他操作系统功能?

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?

编辑 - - 使用KeyCombination.NO_MATCH,我阻止用户退出全屏。但是,操作系统仍然完全能够使用标准键组合退出,或者在OS X的情况下,只需将鼠标移动到屏幕顶部并使用程序菜单退出。

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.

推荐答案

我错过了什么?我认为它的奶酪..
喜欢这个

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);
        }
    });

全屏无人脾气,直到用户按开始按钮隐藏UI 你可以防止这种情况 - 但我建议你只有在关闭你的电脑时才会尝试以下代码

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 是你的阶段

希望你想要的东西

这篇关于如何锁定JavaFX全屏模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆