4

I am making a JavaFX kiosk application that needs to take full control of the screen and disallow closing, minimising, and certain keypresses. I was wondering is there a way to make a JavaFX application run in full screen exclusive mode, if not are there any alternatives that could achieve the same goal. I have tried using:

stage.setFullScreen(true);

which does successfully make the application full screen, however the user can still exit the application or exit the full screen.

  • You could try to override the default-handlers for the actions (exit, minimising). Check out this link for an example: http://stackoverflow.com/questions/17003906/prevent-cancel-closing-of-primary-stage-in-javafx-2-2 – Yser Mar 02 '14 at 00:42

3 Answers3

1

Handle close events.

following code may help!

// Set plat params Platform.setImplicitExit(false);

primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
    @Override
    public void handle(WindowEvent event) {
// deque it
        event.consume();
    }
});
navaltiger
  • 884
  • 12
  • 27
1

I had this same issue recently, hopefully you figured it out (I wouldn't wait 4 years for an answer).

If not:

Before you make a call to stage.show() you need to call setFullScreenExitKeyCombination and pass KeyCombination.NO_MATCH as the only parameter.

so for example...

stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
stage.show()
SeanIdzenga
  • 111
  • 8
0

This will prevent closing and de-fullscreening w/ESC (but still leave you with a backdoor-y way to remove fullscreen - Shift+PAUSE or F13):

scene.setOnKeyPressed((event) ->
{
  if (event.getCode() == KeyCode.PAUSE && event.isShiftDown())
    stage.setFullScreen(!stage.isFullScreen());
});
stage.setOnCloseRequest(Event::consume);
stage.setFullScreenExitKeyCombination(new KeyCodeCombination(KeyCode.F13));

In order to close your application you'd have to add a Platform.exit() on some command.

Unai Vivi
  • 3,073
  • 3
  • 30
  • 46