I see the following code in a Java/Swing GUI project:
MyDialog dlg = new MyDialog(parent, isFizz);
MyDialogResults results = dlg.getResults();
eventBus.fireEvent(new MyDialogEvent(results));
In the code above, MyDialog extends JDialog
. So clearly, a child dialog is being constructed (and somehow shown to the end user), and then when the user exits the dialog (by clicking OK or some other button), a results
bean is used to fire a new event on the event bus.
But I'm struggling with two things:
- How/where is Java being told to actually draw/show the dialog to the user?; and
- How/where is Java being told to hang/wait for the user to exit the dialog, before firing the event to the bus?
Is it that a JDialog
child will always show the dialog when the JDialog
is created, and not return from the constructor until the dialog is exited? Here's the synopsis of hte MyDialog
constructor from above:
public class MyDialog extends JDialog {
private boolean isFizz;
private MyDialogResults results;
// Getters and setters for all properties...
public MyDialog(Frame parent, boolean isFizz) {
super(parent, "My Dialog", true);
setIsFizz(isFizz);
setVisible(true);
dispose();
}
}
Thanks in advance for any help/insight with understanding how the dialog opens, "hangs" (although I know its not actually hung/frozen), closes, and then fires the event.