我在锚点窗格中创建了 fxml 文件
但每次我单击按钮时,我都会在新框架中得到下一个 fxml
我希望它在同一帧中打开
public void baropen(ActionEvent event) {
// handle the event here
BorderPane bp = new BorderPane();
bp.setPadding(new Insets(10, 50, 50, 50));
Stage stage = new Stage();
Scene scene ;
// scene= new Scene(root);
scene = new Scene(bp);
stage.setScene(scene);
stage.show();
try {
new RecBar().start(stage);
} catch (Exception ex) {
Logger.getLogger(RecController.class.getName()).log(Level.SEVERE, null,ex);
}
}
只需创建一个Stage
当你想用新的fxml替换舞台的内容时,将新的fxml加载到新的fxml中Scene
并打电话stage.setScene
.
这是一个戏剧隐喻——想象一下你正在看一场戏剧——这是《罗密欧与朱丽叶》,幕布升起,你看到第一个场景(维罗纳的一个有喷泉的广场)。随后,窗帘降下,小人物跑来跑去换东西,窗帘升起,你看到一个新的场景(朱丽叶卧室的阳台)。场景变了,但舞台没有变——只有一个舞台,多个场景。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)