14
votes

How is it possible to change scene of fullscreen window and avoid to show "Press ESC to exit fullscreen" message?

I'm building fullscreen desktop application (touchscreen kiosk) so I can show this message at the beginning, but now always when user changes scene.

There are two problems:

  1. When in fullscreen and scene is changed, window size is reduced. Solution is to toggle fullscreen, but there is that message shown. (Change scene in full screen JavaFX)

  2. "Press ESC.." message cannot be disable due to security reasons (https://forums.oracle.com/forums/thread.jspa?threadID=2287258)

Thanks.

3

3 Answers

32
votes

JavaFX 8 has solved this problem with the addition of the following 2 methods:

If you set the exit key combination to KeyCombination.NO_MATCH the pop-up message will be disabled completely.

3
votes

on 2. there's going to be a new feature in JavaFX8 to turn that warning of. The current proposal is that there's going to be a command line option. You can see the discussion on the openjfx mailing list (http://markmail.org/search/?q=+javafx.Stage.fullScreenWarning%3Dfalse#query:%20javafx.Stage.fullScreenWarning%3Dfalse+page:1+mid:ptqpgut2vvvhgkip+state:results)

0
votes
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.input.KeyCombination;

public class GameApplication extends Application{
    @Override
    public void start(Stage stage){
        StackPane stackPane=new StackPane();
        Scene scene=new Scene(stackPane,500,500);
        stage.setScene(scene);
        stage.setTitle("Title");
        //Fullscreen
        stage.setFullScreen(true);
        //We don't want to exit the fullscreen when keys are pressed
        stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
        //We are adding a change listener to lock the application in full
        //screen mode only
        stage.fullScreenProperty().addListener(new ChangeListener<Boolean>() {

            @Override
            public void changed(ObservableValue<? extends Boolean> observable,
                    Boolean oldValue, Boolean newValue) {
                if(newValue != null && !newValue.booleanValue())
                    stage.setFullScreen(true);
            }
        });
        stage.show();
    }
    //main method
    public static void main(String ...$){
        launch($);
    }
}