5

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.

Sam Claus
  • 1,807
  • 23
  • 39
  • 2
    You need to have os operate in "kiosk" mode – MadProgrammer Aug 29 '15 at 04:21
  • Thanks! I'll research it. – Sam Claus Aug 29 '15 at 04:23
  • Is there an abstracted way to enter kiosk mode on any platform through JavaFX or the standard packages? I assume not? – Sam Claus Aug 29 '15 at 04:26
  • 1
    No, I doubt it, I think the OS needs to be pre-configured for it, but never having done it I can't say for certain – MadProgrammer Aug 29 '15 at 04:30
  • Okay. If I'm running the application on Windows, do you think locking fullscreen and consuming all window closing events will work? Is there any way to stop key combos like Alt + Tab? – Sam Claus Aug 29 '15 at 04:33
  • As I understand it, it should only allow a single program to run (window)... – MadProgrammer Aug 29 '15 at 04:43
  • That would be optimal, but for this program's use it simply needs to be launched and intercept all user actions. – Sam Claus Aug 29 '15 at 04:46
  • 2
    Have a read, but as I read it, it (at least in Windows 8+) (I think they call it "Assigned Access"), it's based on a user account [Step-By-Step: Enabling Kiosk Mode in Windows 8.1 via Assigned Access](http://blogs.technet.com/b/canitpro/archive/2013/12/17/step-by-step-enabling-kiosk-mode-in-windows-8-1-via-assigned-access.aspx) to allow access to a single application... – MadProgrammer Aug 29 '15 at 04:49
  • As it sounds like there's no way to initiate kiosk mode temporarily using Java, I guess I can change things up and just explain the process of setting up kiosk mode to the client. Thanks! – Sam Claus Aug 29 '15 at 04:53
  • 2
    If it is a windows machine and you need kiosk mode, there is a free tool from mirabyte: http://www.mirabyte.com/en/products/frontface-lockdown-tool/manual.html – aw-think Aug 29 '15 at 08:16

2 Answers2

13

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

Elltz
  • 10,730
  • 4
  • 31
  • 59
  • 1
    Thanks! That's perfect, especially because it will work across all platforms and I don't have to mess with boot settings. – Sam Claus Aug 29 '15 at 15:33
  • The second one works with alt+tab, but it won't work with the Windows key. P.S. I used `java.util.Timer` and `java.util.TimerTask` to do this, since that's better than an infinite loop like this. If you're interested in this, please visit the Javadoc for `java.util.Timer` and `java.util.TimerTask`. – Tech Expert Wizard Nov 30 '20 at 12:45
13

primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

Niraj Tandukar
  • 131
  • 1
  • 2