简体   繁体   English

使用FXML最大化场景-JavaFX2

[英]Maximize Scene with FXML - JavaFX2

I'm looking for a way to maximize a scene with FXML. 我正在寻找一种使用FXML最大化场景的方法。 An equivalent to JFrame.setExtendedState() . 等效于JFrame.setExtendedState() The code primaryStage.setFullScreen(true) behaves differently. 代码primaryStage.setFullScreen(true)行为有所不同。

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();
    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());

This seems to do what I want , but I'd like to set the size with FXML. 这似乎可以满足我的要求,但是我想使用FXML设置大小。 To keep GUI code separated from the logic! 为了使GUI代码与逻辑分离! Thank you in advance, have a nice day! 在此先感谢您,祝您度过愉快的一天!

我不确定这是否是您要寻找的东西,但是您可以尝试

primaryStage.setMaximized(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM