[英]is it possible to open a new fxml file in the same frame
我已經在錨定窗格中創建了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加載到新的Scene
並調用stage.setScene
。
這是一個劇院隱喻-想像您正在看一場戲-是羅密歐與朱麗葉,幕布升起,您會看到第一個場景(維羅納廣場上有噴泉的廣場)。 稍后,窗簾降下,小矮人跑來跑去,換東西,窗簾升起,您會看到一個新的場景(朱麗葉卧室的陽台)。 場景已更改,但舞台沒有更改-只有一個舞台和多個場景。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.