JavaFX应用自定义全屏退出规则失效,无法退出全屏的问题求助
JavaFX应用自定义全屏退出规则失效,无法退出全屏的问题求助
最近在学JavaFX,想做个小功能——只有输入"abcd"才能退出全屏模式,结果试了各种办法都不管用,现在完全退不出全屏了,求大佬帮忙看看哪里错了😭
我设置了全屏退出提示,也指定了退出的键组合,但就是没效果。用的是JavaFX 17和Java 18版本。
以下是我写的代码:
package org.example.first; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.input.KeyCombination; import javafx.scene.paint.Color; import javafx.stage.Stage; import java.io.IOException; public class HelloApplication extends Application { @Override public void start(Stage stage) throws IOException { Group root = new Group(); Scene scene = new Scene(root, Color.BLACK); Image icon = new Image("file.png"); stage.setTitle("MyApplication"); stage.setScene(scene); stage.getIcons().add(icon); stage.setFullScreen(true); stage.setFullScreenExitHint("To exit fullscreen, write abcd"); stage.setFullScreenExitKeyCombination(KeyCombination.valueOf("abcd")); stage.show(); } public static void main(String[] args) { launch(); } }
备注:内容来源于stack exchange,提问作者armenia
相关产品推荐
相关产品推荐

