Javafx使用按钮在另一个窗口中打开另一个fxml [英] Javafx open another fxml in the another window with button

查看:1104
本文介绍了Javafx使用按钮在另一个窗口中打开另一个fxml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javafx是否可以通过按钮从另一个fxml打开新阶段(窗口)?
感谢您的回答。

Is it possible in javafx to open new stages (windows) from another fxml with a button? Thanks for the answers.

推荐答案

使用以下代码点击按钮

      try{
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Demo.fxml"));
            Parent root1 = (Parent) fxmlLoader.load();
            Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initStyle(StageStyle.UNDECORATED);
            stage.setTitle("ABC");
            stage.setScene(new Scene(root1));  
            stage.show();
          }

这篇关于Javafx使用按钮在另一个窗口中打开另一个fxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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