You could check if the "selection" follows the focus, e.g. by calling setFocus() on the window/parent before you show the dialog.

Cheers,
_