【问题标题】:how to return to back to the full screen in javafx after press ESC to exit full screen mode?按ESC退出全屏模式后如何在javafx中返回全屏?
【发布时间】:2019-07-23 11:32:21
【问题描述】:

我想让功能在按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

然后在这个阶段,我希望回到全屏模式。

【问题讨论】:

  • stage.setFullScreen(true)?
  • 我的意思是..当我按ESC,然后如何再次进入全屏模式?
  • 还是不明白:你想达到什么目的?究竟是什么问题?请提供一个minimal reproducible example 来说明问题。
  • 有意义吗?
  • @kleopatra nvm,我解决了这个问题。谢谢

标签: java eclipse javafx


【解决方案1】:

使用 ESC(或任何其他键)防止退出全屏:

stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

如果你不是全屏,创建一个listener方法去全屏执行:

stage.setFullScreen(true);

【讨论】:

    猜你喜欢
    • 2014-10-21
    • 2023-04-03
    • 1970-01-01
    • 2020-03-03
    • 2013-05-18
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2015-03-15
    相关资源
    最近更新 更多