What you want is for your dialog to be modal. Use Dialog.setModal(boolean)
:
public MyFrame() throws IOException {
setModal(true);
Then when you call setVisible
on the dialog from the code that constructed it, the code will wait until the dialog is closed.