Если диалоговое окно является модальным, то код блокируется, пока диалоговое окно не будет закрыто:
dialog.setVisible(true);
// blocked here until the dialog is closed. The dialog stores the input in a
// field when OK is clicked in the dialog
if (dialog.getTextInputtedByTheUser() != null) {
...
Если диалоговое окно не является модальным, тогда вам нужно заставить его вызывать метод обратного вызова, когда происходит проверка. Это то, что MyFrame будет содержать
private void showDialog(
MyDialog dialog = new MyDialog(this);
dialog.setVisible(true);
}
public void userHasInputSomeText(String text) {
// do whatever you want with the text
System.out.println("User has entered this text in the dialog: " + text);
}
и в MyDialog:
private MyFrame frame;
public MyDialog(MyFrame frame) {
super(frame);
this.frame = frame;
}
...
private void okButtonClicked() {
String text = textField.getText();
frame.userHasInputSomeText(text);
}