How to transfer Value form modal Dialog to the Parent Window?

I am using RapidClipseX with Vaadin14 in compatibility mode.
I have not so much experience in Vaadin and Java

I created a UI component with Vaadin dialog based on an example.
I could call the dialog and work within it without problems.
Inside the dialog I select values out of a grid.
After selection I would like to give the selected value back to the parent window.
I use pure java.

With following code I call the dialog and there I expect the return value given back by the dialog:

	// Call to open the Modal Dialog by click on button:
	private void btnOpenFileDialog_onClick(final ClickEvent<Button> event)
	{
		new FileOpenDialog()
		.setSavedCallback(()-> {

		// Something has to be done here, to receive the selected Entity?

        })
		.open();
		
	}

Following code shows a part of the content of my Dialog-component:

public class FileOpenDialog extends Dialog
{
	

	Logger logger = LoggerFactory.getLogger(this.getClass());

	private Runnable listener;
	private byte[] bytes;

	
	public  FileOpenDialog()
	{
		super();
		this.initUI();
		
        //-- do something

	}

	public FileOpenDialog setSavedCallback(final Runnable listener)
	{
		this.listener = listener;
		return this;
	}

	public FileOpenDialog setFileObject(final hlpClFileobjects myFileObject)
	{
		this.myFileObject=myFileObject;
		return this;
	}

    //...
	private void grdFiles_selectionChange(final SelectionEvent<Grid<hlpClFileobjects>, hlpClFileobjects> event)
	{
		this.logger.info("a row out of grid was selected");
		if(event.getFirstSelectedItem().isPresent())
		{
			final hlpClFileobjects selectedEntity = this.grdFiles.getSelectedItems().stream().findFirst().get();
			this.setFileObject(selectedEntity);

// Something has to be done here, to hand over the selected Entity?


			this.close();
		}
	}
} // End of class FileOpenDialog

I searched here, in Stackoverflow and general in internet, but found nothing which I can use to transfer for my example
It would be fine, if I could get a hint or an example code
Thank you in advance!

You can add addOpenedChangeListener to the dialog and then pass one or more values back e.g. via a getter from the Dialog.

dialog.addOpenedChangeListener(ee->
{
     if(!ee.isOpened()) {
		 dialog.getSelection();

Thank you very much! This hint helpt me to get it running.
In the button to open the dialog I changed the code to:

private void btnOpenFileDialog_onClick(final ClickEvent<Button> event)
	{
		final FileOpenDialog myDialog = new FileOpenDialog();

		myDialog.addOpenedChangeListener(ev ->
		{
			if (!ev.isOpened())
			{
				final hlpClFileobjects myFileObject = myDialog.getFileObject();
				System.out.println("a.) " + myFileObject.getFileName() + " / " + myFileObject.getId());
			}
		});
		
		myDialog.setSavedCallback(()-> { })
		.open();
	}

And inside the dialog I created a getter:

	public hlpClFileobjects getFileObject()
	{
		return this.myFileObject;

	}