I would like create new Stage using actual Controller, because I need to have access to Base where I keep the data. In the new window I want to add new users to my Base class, and after returning to the main window I want to have access to the class Base in which I added new people. How I can do this?
public class Controller {
private Base base;
@FXML private TextField email;
public void addPersonButtonClicked(ActionEvent event) throws IOException {
Parent mainView = FXMLLoader.load(getClass().getResource("addPerson.fxml"));
Scene mainViewScene = new Scene(mainView);
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(mainViewScene);
window.show();
}
public void addPersonContinueClicked(){
Person person = new Person();
person.setEmail(email.getText());
base.addPerson(person);
}
}
Edit: Base.class
public class Base {
private List<Person> personList = new ArrayList();
public Base() {
}
public void addPerson(Person person) {
if (this.personList.contains(person)) {
throw new RuntimeException();
} else {
this.personList.add(person);
}
}
}