在我的应用程序中,我正在切换 fxml 文件以更改视图,因为我不正确地了解 Scene 和 Parent 根的概念。我所有的 fxml 文件都有一个 AnchorPane(600,400)。这就是我的启动方法的样子。
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("loginpage.fxml"));
primaryStage.setTitle("Eye Ratina Scanner");
primaryStage.setScene(new Scene(root, 600, 400));
primaryStage.show();
}
这就是我改变观点的方式。
AnchorPane pane = FXMLLoader.load(getClass().getResource("../loginpage.fxml"));
dashpane.getChildren().setAll(pane) //dashpane is AnchorPane
我制作了 600:400 大小的整个应用程序。现在我希望当我单击窗口最大化按钮时,所有组件都会调整大小并保持比例。下面附有两张图片以显示正在发生的事情。当我点击最大化
现在我不想绑定每个按钮、图像视图、锚窗格、文本字段、标签等。因为我有大约 42 个 fxml 文件,所以需要很长时间。我们可以通过一个片段来实现我们的结果吗?我没有发现任何其他帖子具有完全相同的问题。
感谢您提前回答。我非常感谢你的帮助。