這個問題在這里已經有了答案: JavaFX 將新的 fxml 檔案加載到同一場景中 1 個答案 昨天關門。
我想重新加載我的 Java Fx 專案場景。
所以我創建了一個按鈕,它有一個 Fx-ID
現在我想創建一些東西,在按下按鈕后重新加載整個 fx 場景......
這怎么可能。?
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load());
stage.setTitle("!");
stage.setScene(scene);
stage
這是我的場景
uj5u.com熱心網友回復:
嘗試
Stage close = (Stage) restart.getScene().getWindow();
close.close();
Stage stage = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load());
stage.setTitle("!");
stage.setScene(scene);
stage.show();
}
這應該有助于關閉你的舞臺。您還將創建另一個階段,洗掉輸入
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/428159.html
上一篇:具有2行寬度大小的Wpf網格
