is it possible to open a new fxml file in the same frame

后端 未结 1 1408
囚心锁ツ
囚心锁ツ 2021-01-26 01:15

i\'ve created fxml files in anchor pane but everytime i click on the button i get the next fxml in a new frame i want it to open in the same frame

public void ba         


        
1条回答
  •  不思量自难忘°
    2021-01-26 01:42

    Just create a single Stage and when you want to replace the content of the stage with a new fxml, load the new fxml into a new Scene and call stage.setScene.

    It's a theater metaphor - imagine you are watching a play - it's Romeo and Juliet, the curtain raises and you see the first scene (a plaza in Verona with a fountain). Later on, the curtain lowers, little men run around and change stuff, the curtain rises and you see a new scene (the balcony to Juliet's bedroom). The scene has changed, but the stage has not - there is just one stage and multiple scenes.

    0 讨论(0)
提交回复
热议问题