How to let the code wait until users select one radio button from Dialog?

My purpose: when there are multiple modules in a project, I will ask users to select the module they want to use.

My implementation logic is as follows. 

1. Check the number of modules in a project.

2. If it has multiple ones, I will user class DialogWrapper to create a dialog.

3. In the dialog, it includes some radio buttons where each button corresponding to one module.

4. Users choose one radio button, then click "OK".  I will select the module corresponding to the one users select.

Now, the issue is, the code after the Dialog will be executed before the Dialog appears. The code is as follows:

if (number of modules > 1){
ApplicationManager.getApplication().invokeLater(
createDialog()
if( users select one radio button && click "OK"){
do some things.
}
)

do following things.
}

The program will "do following things." before "do some things." I think there are some issues about the thread. But I don't know how to deal with it. Any suggestions will be very helpful. Thanks in advance!

请先登录再写评论。