14

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.

4

3 回答 3

32

JavaFX 8 通过添加以下 2 种方法解决了这个问题:

如果您将退出组合键设置为KeyCombination.NO_MATCH弹出消息将被完全禁用。

于 2013-12-05T13:03:13.123 回答
3

关于 2. JavaFX8 中将有一个新功能来消除该警告。目前的提议是会有一个命令行选项。您可以在 openjfx 邮件列表中看到讨论(http://markmail.org/search/?q=+javafx.Stage.fullScreenWarning%3Dfalse#query:%20javafx.Stage.fullScreenWarning%3Dfalse+page:1+mid: ptqpgut2vvvhgkip+状态:结果

于 2013-05-23T12:44:46.563 回答
0
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($);
    }
}
于 2021-09-01T06:12:01.037 回答