您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

全屏阶段在JavaFX 2.1中无法正常工作?

全屏阶段在JavaFX 2.1中无法正常工作?

我不知道真正的原因,但是这里有2个快速解决方法。 在handleButtonAction方法中: 不要创建新场景,只需替换其内容

  @FXML
  private void handleButtonAction(ActionEvent event) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
    JavaFXApplication12.currentStage.getScene().setRoot(root);
  }

如果您确实需要创建新场景,则切换全屏

  @FXML
  private void handleButtonAction(ActionEvent event) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
    JavaFXApplication12.currentStage.setScene(new Scene(root));
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
           JavaFXApplication12.currentStage.setFullScreen(false);
           JavaFXApplication12.currentStage.setFullScreen(true);
       }
    });
  }
java 2022/1/1 18:35:25 有540人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶