Macos 按下cmd+;时退出JavaFx全屏;Q

Macos 按下cmd+;时退出JavaFx全屏;Q,macos,javafx,fullscreen,kiosk-mode,Macos,Javafx,Fullscreen,Kiosk Mode,按下OSX中的cmd+q时,JavaFx全屏退出。即使捕获onCloseRequest事件也不能帮助应用程序不退出全屏。 有人面临这个问题吗?如何禁用此行为并允许应用程序始终全屏显示 感谢您的帮助 下面是我正在尝试的代码 public class FullScreenScene extends Application { /** * @param args * the command line arguments */ public static void main

按下OSX中的cmd+q时,JavaFx全屏退出。即使捕获onCloseRequest事件也不能帮助应用程序不退出全屏。 有人面临这个问题吗?如何禁用此行为并允许应用程序始终全屏显示

感谢您的帮助

下面是我正在尝试的代码

public class FullScreenScene extends Application {

/**
 * @param args
 *            the command line arguments
 */
public static void main(String[] args) {
    launch(args);
}

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("TilePane");

    // Adding StackPane
    StackPane sp = new StackPane();
    Text txt = new Text("This is a full screen JavaFX 2 Scene...");
    txt.setFont(Font.font(null, FontWeight.BOLD, 72));
    txt.setFill(Color.RED);
    sp.getChildren().add(txt);

    // Adding StackPane to the Scene
    Scene scene = new Scene(sp);
    primaryStage.setScene(scene);
    // Set full screen
    primaryStage.setFullScreen(true);
    primaryStage.setOnCloseRequest(ev -> {
        ev.consume();
    });
    primaryStage.show();
  }
}

您是否尝试调用
.setresizeable(false)在primaryStage?我不知道OSX,但这里有一个可以帮助您。顺便说一句,我建议使用
Stage#setMaximized(true)
和适当的
StageStyle
而不是全屏,特别是当应用程序可以在两屏计算机上启动时。setresizeable(false)在Java 8 update 25中有效,但在Java 8 update 144中无效。