微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

按下ESC退出全屏模式后,如何在javafx中返回全屏?

我要使功能在按ESC退出全屏模式后返回全屏模式.

有什么方法可以返回全屏显示吗?

例如,
要执行全屏模式,我使用了以下方法

@Override
public void init(Controller controller) {
    sound.backgroundMusic();
    menuButtons = new ArrayList<>();
    createSubScenes(controller);
    createButtons(controller);
    createBackground();
    createlogo();
    controller.setScene(mainScene);

}

public void setScene(Scene scene) {
    Platform.runLater(() -> stage.setScene(scene));
    Platform.runLater(() -> stage.setFullScreen(true));
}

在舞台上,当我按ESC时,舞台退出到全屏.
enter image description here

enter image description here

然后在这个阶段,我希望能够返回到全屏模式.

最佳答案
防止通过ESC(或其他任何键)使用全屏模式:

stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

如果您不处于全屏模式,请创建一个侦听器或方法以全屏执行:

stage.setFullScreen(true);

原文地址:https://www.jb51.cc/java/532866.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐