JavaFx:如何保持窗口最大化? [英] JavaFx: How to keep the window maximizing?

查看:745
本文介绍了JavaFx:如何保持窗口最大化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用,如果我点击最大化按钮,它将最大化窗口。但是如果我去另一个场景(在同一个舞台上),窗口将恢复到原始大小。那么,我该如何控制它以保持最大化?

My app, if I click the "maximize button", it will maximize the window. But if I go to another scene(in the same stage), the window will restore to the original size. So, how can I control it to keep maximizing?

推荐答案

我就是这样做的:

@FXML
private Button goBtn;

Stage stage = (Stage) goBtn.getScene().getWindow();
Scene scene = goBtn.getScene();
try {
   FXMLLoader loader = new FXMLLoader(getClass().getResource("Activity.fxml"));
   scene.setRoot(loader.load());
   stage.setScene(scene);
   stage.show();
} catch (IOException e) {
   e.printStackTrace();
}

这篇关于JavaFx:如何保持窗口最大化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆