Есть окно: public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("My First App");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
в нем есть кнопка "new window", который переходить к другой окно:
@FXML private Button id;
@FXML
void initialize() {
id.setOnAction(event -> {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/sample/ex1.fxml"));
try {
loader.load();
} catch (IOException e) {
e.printStackTrace();
}
Parent root = loader.getRoot();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
});
в новом окне(ex1.fxml) есть кнопка "Cancel", Kaк оформить кнопку "Cancel" так, чтоб это окно зокрывался,и перещоль переведущую оконо: "sample.fxml".п.с. не нужен создать новый "sample.fxml", а именно возврашатся переведущую оконо. Спосибо!