Connecting a controller to your application fxml

I am creating an application that requires the user to set a password. My password scene is written in fxml. After the user clicks the register button I would like the controller to notify the main application and give it the password so it can use it Currently I am doing that by subclassing the controller like so

    class RegisterClass
{
    private Stage stage = new Stage();
    private Scene scene;
    @FXML PasswordField secondpass;
    @FXML PasswordField firstpass;
    @FXML Label error;
    @FXML Button register;
    public RegisterClass()
    {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/com/quagrum/resources/fxml/register.fxml"));
        Pane par = null;


        fxmlLoader.setController(this);
         try {
                par = fxmlLoader.load();
            } catch (IOException exception) {
                throw new RuntimeException(exception);
            }
         scene= new Scene(par,219,240);
         stage.setScene(scene);
         stage.getIcons().add(new Image(getClass().getResource("/com/quagrum/resources/images/NewQuagrumIco.png").toString()));
            scene.setOnKeyPressed(new EventHandler<KeyEvent>()
            {
                @Override
                public void handle(KeyEvent ke)
                {
                    if (ke.getCode().equals(KeyCode.ENTER))
                    {
                        register.fire();
                    }
                }
            });
            stage.setOnCloseRequest(e->{
                System.exit(0);
            });
            stage.showAndWait();
    }
    @FXML
    private void initialize() {

        register.setOnAction(e->{

            if(firstpass.getText().equals(secondpass.getText()))
            {
                if(firstpass.getText().length()==0)
                {
                    password=firstpass.getText();
                    createLock();
                    stage.close();
                }else
                {
                    password=firstpass.getText();
                    createLock();
                    stage.close();
                }

            }else
            {
                error.setText("Passwords do not match");
                error.setVisible(true);
            }
        });

    }
}
private void register()//this one setups all the accounts with the new password
{
    RegisterClass register = new RegisterClass();
}

However, this makes my code in the parent class much longer as I have also done the same thing with the login page. So my question is, is there a way I can create a seperate controller class that will interact with the caller and send the passwords or is this currently the best way.