I can't figure out a way to get my program work. How can I fix the issue?
Main.java
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class Main extends Application {
    private Stage window;
    public void start(Stage window) throws Exception {
        this.window = window;
        this.window.setTitle("test");
        initLayouts();
    }
    public void initLayouts() throws Exception{
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(ClassLoader.getSystemResource("sample.fxml"));
        BorderPane rootLayout = (BorderPane)loader.load();
        Scene scene = new Scene(rootLayout);
        window.setScene(scene);
        window.show();
        loader = new FXMLLoader();
        loader.setLocation(ClassLoader.getSystemResource("content.fxml"));
        AnchorPane ap = (AnchorPane)loader.load();
        rootLayout.setCenter(ap);
        ContentController controller = loader.getController();
        controller.setMain(this);
    }
    public void showEditWindow() throws Exception{
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(ClassLoader.getSystemResource("editWindow.fxml"));
        AnchorPane ap = (AnchorPane)loader.load();
        Stage editWindow = new Stage();
        editWindow.setTitle("Add");
        editWindow.initModality(Modality.WINDOW_MODAL);
        editWindow.initOwner(window);
        Scene scene = new Scene(ap);
        editWindow.setScene(scene);
        EditController controller = loader.getController();
        controller.setStage(editWindow);
        editWindow.showAndWait();
    }
    public static void main(String[] args) {
        launch(args);
    }
}
EdiController.java
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import java.io.IOException;
public class EditController{
    @FXML
    TextField textField = new TextField();
    @FXML
    Button button;
    private Stage stage;
    private ContentController contentController;
    public void setStage(Stage stage){
        this.stage = stage;
    }
    @FXML
    private void buttonClicked() throws IOException {
        assert(contentController != null);
        assert(textField != null);
        assert(button != null);
        contentController.setLabel(textField.getText());
        stage.close();
    }
}
ContentController.java
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
public class ContentController {
    @FXML
    private Button add;
    @FXML
    private Button clear;
    @FXML
    public Label label;
    private Main main;
    public void setMain(Main main){
        this.main = main;
    }
    public void setLabel(String label){
        this.label.setText(label);
    }
    @FXML
    private void clearLabel(){
        label.setText("");
        System.out.println("text removed");
    }
    @FXML
    private void addClicked() throws Exception {
        main.showEditWindow();
    }
}
The main issue seems to be on the lane of EditController.java 'contentController.setLabel(textField.getText());' this is what always causes the issue. What options do I have to fix it? Thanks in advance
